Follow Our FB Page << CircleMedia.in >> for Daily Laughter. We Post Funny, Viral, Comedy Videos, Memes, Vines...


What is Copy Constructor?

Answers were Sorted based on User's Feedback



What is Copy Constructor?..

Answer / swetcha

The purpose of a copy constructor is to initialize a new
object of a given class by copying an existing object of
that class.

Is This Answer Correct ?    62 Yes 3 No

What is Copy Constructor?..

Answer / srikanth kanchari

Copy constructor is created by the compiler if you dont
Create, but it does shallow Copy of the Object so there is
a need to create a copy constructor by the Developer to
make deep copy of the object.

Normally it will be

Class A
{
A();
A(A&);// copy constructor
};

Is This Answer Correct ?    18 Yes 7 No

What is Copy Constructor?..

Answer / sanjay gupta

COPY CONSTRUCTOR IS A SPECIAL CONSTRUCTOR IN C++ PROGRAMMIN
LANGUAGE FOR CREATING A NEW OBJECT AS A COPY OF AN EXISTING
OBJECT

Is This Answer Correct ?    5 Yes 2 No

What is Copy Constructor?..

Answer / shrikant kale

I think the answer to this is very interesting.

For one, I believe that in Java all objects are on the
heap, and while you don't have pointers, you do
have "References". References have copy symantics and java
internally keeps track of reference counts so that it's
garbage collector knows whats safe to get rid of.

Since you only access objects through copyable references,
the actual number of times you need to copy an object is
greatly reduced (for example, in C++ just passing an object
to a function (by value) results in new objects being copy
constructed, in Java only the reference to the object is
passed). The designers probably figured that clone() would
be enough for the remaining uses.

Is This Answer Correct ?    1 Yes 0 No

What is Copy Constructor?..

Answer / naveen kumar

The copy constructor is a constructor which creates an object by initializing it with an object of the same class, which has been created previously.

Is This Answer Correct ?    1 Yes 0 No

Post New Answer



More C++ Interview Questions

When must you use a constructor initializer list?

0 Answers   Amazon,


Without using third variable write a code to swap two numbers.

0 Answers   Accenture,


Discuss the role of C++ shorthands.

0 Answers   Adobe,


What is an algorithm (in terms of the STL/C++ standard library)?

0 Answers   Amazon,


What is Copy Constructor?

5 Answers   ABC, Siemens,






How does stack look in function calls? When does stack overflow? What can you do to remedy it?

0 Answers   Adobe,


What are "pure virtual" functions?

0 Answers   Adobe, Alter, iNautix,


What does it mean to declare a member function as virtual in C++?

0 Answers   Amazon,


What is an abstract class?

4 Answers   Siemens,


How do you write a function that can reverse a linked-list in C++?

0 Answers   IBS,


Write a C++ program to print strings in reverse order.

0 Answers   Amdocs,


What is a virtual base class?

6 Answers   Fidelity, Siemens,






Categories