Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


WHEN A COPY CONSTER IS CALL ?

Answers were Sorted based on User's Feedback



WHEN A COPY CONSTER IS CALL ? ..

Answer / preeti

There are 3 important places where a copy constructor is
called.

When an object is created from another object of the same
type
When an object is passed by value as a parameter to a
function
When an object is returned from a function

class A //With copy constructor
{
private:
char *name;
public:
A()
{
name = new char[20];
}
~A()
{
delete name[];
}
//Copy constructor
A(const A &b)
{
name = new char[20];
strcpy(name, b.name);
}
};

Is This Answer Correct ?    9 Yes 0 No

WHEN A COPY CONSTER IS CALL ? ..

Answer / achal ubbott

Question on copy constructor is a classic one for an
interview. Since most modern day c++ compilers provide a
default copy constructor, most people don't get to try
hands over it. But in some cases it becomes mandatory to
define your own copy constructor and override the default
one.
So the places when CC is invoked are:-

1. calling a function e.g. void f(sample A);

2. creating an object from the existing object.
e.g. sample A=B; // here B is existing object.

3. When a function returns a copy of object.

e.g. sample f()
{
sample a;
return a;
}

Is This Answer Correct ?    2 Yes 0 No

WHEN A COPY CONSTER IS CALL ? ..

Answer / vishwa

emp e;//default constr
emp e(10);//paramatrisized constr
emp e(e1);//copy constr
emp e = e1;//copy constr

Is This Answer Correct ?    2 Yes 0 No

WHEN A COPY CONSTER IS CALL ? ..

Answer / muthu_tek

emp e;//default constr
emp e(10);//paramatrisized constr
emp e(e1);//copy constr

Is This Answer Correct ?    1 Yes 4 No

Post New Answer

More OOPS Interview Questions

what is static?

4 Answers  


What is the use of oops?

0 Answers  


What is polymorphism? Explain with an example.

48 Answers  


What are the OOPS concepts?

106 Answers   A1 Technology, Bajaj, CTS, EDS, HP, Infosys, Intel, Microsoft, MNC, Persistent, PlanetSoft, ProConstructor, TCS, Virtusa, Wipro, YSoft Solutions,


Can we have a private constructor ?

12 Answers   HSBC, Ness Technologies, TCS, Wipro,


They started with the brief introduction followed by few basic C++ questions on polumorphism, inheritance and then virtual functions. What is polymorphims? How you will access polymorphic functions in C? How virtual function mechanism works?

0 Answers  


what is oops

4 Answers   NIIT,


What is property in oops?

0 Answers  


How to calculate the age from the date of birth by using the program?

2 Answers   Accenture,


i had specified the access specifier for abstarct class member like (pure virtual function) as private.But it can be accessed by the derived class.How the private member of one class is accessed by other class.if any body face this problem and found the solution plz reply to me.

1 Answers   Syntel,


what is meant by files?

4 Answers   Infosys,


Which is the parameter that is added to every non-static member function when it is called?

3 Answers   Accenture,


Categories