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
Explain operator overloading.
Difference between strdup and strcpy?
Can class objects be passed as function arguments?
What's the order in which the objects in an array are destructed?
What is #include sstream?
How does java differ from c and c++?
Define basic type of variable used for a different condition in C++?
What is a far pointer? where we use it?
What is the use of endl in c++?
What are virtual constructors/destructors?
Does there exist any other function which can be used to convert an integer or a float to a string?
Can we use clrscr in c++?
When does the c++ compiler create temporary variables?
What is nested class in c++?
What is an adaptor class or wrapper class in c++?