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

What is encapsulation in c++?

1378


Why is main function important?

1175


Which of the following is evaluated first: a) && b) || c) !

2421


What is format for defining a structure?

1139


What is a block in c++?

1101


Which software is used to run c++ program?

1048


What is an operator in c++?

1121


How to defines the function in c++?

1220


Describe new operator?

1214


What is a float in c++?

1035


What is virtual base class uses?

1450


What do you mean by storage classes?

1662


Is rust better than c++?

1173


Explain how a pointer to function can be declared in C++?

1108


Will a catch statement catch a derived exception if it is looking for the base class?

1064