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
What is encapsulation in c++?
Why is main function important?
Which of the following is evaluated first: a) && b) || c) !
What is format for defining a structure?
What is a block in c++?
Which software is used to run c++ program?
What is an operator in c++?
How to defines the function in c++?
Describe new operator?
What is a float in c++?
What is virtual base class uses?
What do you mean by storage classes?
Is rust better than c++?
Explain how a pointer to function can be declared in C++?
Will a catch statement catch a derived exception if it is looking for the base class?