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 can we use copy constructor?

Answer Posted / amar

Copy constructors is used in following cases.
1) When object is passed by values to a fucntion
2) when function returns object by value
3) When new object is created from exixting object using
overlaoded = operator.

If user has not defined its own copy constructor, compiler
synthesised constructor would be called which will do
shallow copy. So if you have pointer in your class then only
the pointer value is copied and not the contents which
pointer points to.

Is This Answer Correct ?    12 Yes 5 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain operator overloading.

995


Difference between strdup and strcpy?

1135


Can class objects be passed as function arguments?

1009


What's the order in which the objects in an array are destructed?

1336


What is #include sstream?

1007


How does java differ from c and c++?

922


Define basic type of variable used for a different condition in C++?

1046


What is a far pointer? where we use it?

1016


What is the use of endl in c++?

972


What are virtual constructors/destructors?

939


Does there exist any other function which can be used to convert an integer or a float to a string?

1025


Can we use clrscr in c++?

1020


When does the c++ compiler create temporary variables?

986


What is nested class in c++?

893


What is an adaptor class or wrapper class in c++?

1094