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 is the use of default constructor?

563


How can you say that a template is better than a base class?

576


Explain the uses oof nested class?

617


What are the benefits of c++?

562


what kind of projects are suitable for c and c++

613






what are the iterator and generic algorithms.

1455


Explain the virtual inheritance in c++.

586


Write a program to add three numbers in C++ utilizing classes.

614


If I is an integer variable, which is faster ++i or i++?

582


What is overloading unary operator?

591


What are smart pointers?

666


What is cin clear () in c++?

601


What is private, public and protected inheritance?

583


What is c++ best used for?

556


Is map ordered c++?

584