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

When should you use global variables?

893


Explain explicit container.

848


How do you print a string on the printer?

778


What is c++ best used for?

777


What is a manipulative person?

738


How does the copy constructor differ from the assignment operator (=)?

849


What does return 0 do in c++?

807


What is runtime errors c++?

800


When should we use container classes instead of arrays?

790


What is the use of :: operator in c++?

813


What is an adjust field format flag?

873


What is a static element?

796


What are structs in c++?

782


What does 7/9*9 equal ? a) 1 b) 0.08642 c) 0

748


What does the ios::ate argument do?

909