when can we use copy constructor?

Answer Posted / namitha

A copy constructor is used in the following cases.
-When an object is created from another object of the same
type.
-When an object is passed by value as a parameter to a
function.
-When an object is returned from a pointer.
-when we want to set a default value for the data members.

Is This Answer Correct ?    4 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are its advantages and disadvantages of multiple inheritances (virtual inheritance)?

607


Tell me an example where stacks are useful?

596


Why cstdlib is used in c++?

585


What is overloading unary operator?

606


Difference between inline functions and macros?

600






What's the hardest coding language?

576


What is singleton pattern in c++?

550


What are function prototypes?

650


Difference between an inspector and a mutator

777


What are the advantages of pointers?

602


What is boyce codd normal form in c++?

698


What is pair in c++?

630


Explain terminate() function?

596


What is isdigit c++?

579


Do you know the problem with overriding functions?

574