What is Copy Constructor?
Answers were Sorted based on User's Feedback
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 ? | 19 Yes | 7 No |
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 |
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 |
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 |
It is possible to build a C++ compiler on top of a C compiler. How would you do this?
What is an abstract class in C++
0 Answers SwanSoft Technologies,
Implement a 2D bit-matrix representing monochrome pixels which will have only OFF/ON values and will take on an average only one bit of memory for each stored bit. How to perform various operations on it?
What are pass by value and pass by reference?what is the disadvantage of pass by value?
Write a program to input an integer from the keyboard and display on the screen “WELL DONE” that many times.
When would you choose to return an error code rather than throw an exception?
Write a syntax and purpose of switch statement.
How does stack look in function calls? When does stack overflow? What can you do to remedy it?
Can we call C++ OOPS? and Why
What is a memory leak in C++?
What kind of problems does name mangling cause?
There is a base class sub, with a member function fnsub(). There are two classes super1 and super2 which are sub classes of the base class sub.if and pointer object is created of the class sub which points to any of the two classes super1 and super2, if fnsub() is called which one will be inoked?