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

Assume an array of structure is in order by studentID field of the record, where student IDs go from 101 to 500. Write the most efficient pseudocode algorithm you can to find the record with a specific studentID if every single student ID from 101 to 500 is used and the array has 400 elements. Write the most efficient pseudocode algorithm you can to find a record with a studentID near the end of the IDs, say in the range from 450 to 500, if not every single student ID in the range of 101 to 500 is used and the array size is only 300

2187


What is the error in the code below and how should it be corrected?

725


Write some differences between an external iterator and an internal iterator? Describe the advantage of an external iterator.

1033


What is while loops?

1011


How do I write a c++ program?

1076


What is the use of volatile variable?

1041


What doescout<<(0==0) print out a) 0 b) 1 c) Compiler error: Lvalue required

943


Define anonymous class.

1042


What do you understand by pure virtual function? Write about its use?

971


Which is the best c++ software?

1056


What is encapsulation in c++?

1233


What flag means?

914


What is a storage class?

1209


Can I have a reference as a data member of a class? If yes, then how do I initialise it?

1188


Can user-defined object be declared as static data member of another class?

996