when can we use copy constructor?

Answers were Sorted based on User's Feedback



when can we use copy constructor?..

Answer / richa

A copy constructor is used in 3 cases.They are listed below:
a)When an object is created from another object of the same
type.
b)When an object is passed by value as a parameter to a
function.
c)When an object is returned from a pointer.

Is This Answer Correct ?    38 Yes 9 No

when can we use copy constructor?..

Answer / 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

when can we use copy constructor?..

Answer / sagarson

Copy constructors are called in following cases:
a) when a function returns an object of that class by value
b) when the object of that class is passed by value as an
argument to a function
c) when you construct an object based on another object of
the same class
d) When compiler generates a temporary object

Is This Answer Correct ?    7 Yes 1 No

when can we use copy constructor?..

Answer / 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

when can we use copy constructor?..

Answer / ram

ishwarya rai is so beautiful but now she is wife of bachan so how to get another ishwarya very simple by using copy constructor we will get another ishwarya rai

Is This Answer Correct ?    1 Yes 0 No

when can we use copy constructor?..

Answer / praveen

A copy constructor is used in the following cases.
* When compiler generates a temporary object.
* When an object is return type of pointer.
* This is a temporary object.

Is This Answer Correct ?    2 Yes 3 No

Post New Answer

More C++ General Interview Questions

What is == in programming?

0 Answers  


What is the type of this pointer in c++?

0 Answers  


Explain overriding.

0 Answers  


List the types of polymorphism in c++?

0 Answers  


What is the use of static functions?

10 Answers   Symphony,






why is iostream::eof inside a loop condition considered wrong?

0 Answers  


What is vectorial capacity?

0 Answers  


Design a program to input a date from user in the form day/month/year (e.g. 2/6/2000) and report whether it’s a valid date or not. The program should take account of leap years. You will need to know that a leap year is a year that is exactly divisible by 4, except that century years are only leap years if they are divisible by 400.

1 Answers  


How long it will take to learn c++?

0 Answers  


What is public, protected, private in c++?

0 Answers  


Are c and c++ different?

0 Answers  


What are the general quetions are in DEna bank manager IT/System interviews?

0 Answers   Dena Bank, ICICI,


Categories