What is Copy Constructor?

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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Can you pass a vector to a function?

524


What is split a string in c++?

680


What is a sequence in c++?

566


What is microsoft c++ redistributable 2013?

559


What is the point of polymorphism?

577






Explain overriding.

592


Is c++ an integer?

562


What is a v-table?

636


what is graphics

1996


What is functions syntax in c++?

606


Can non graphic characters be used and processed in C++?

689


c++ program to swap the objects of two different classes

1749


Why Pointers are not used in C++?

608


What is the difference between Stack and Queue in C++?

534


Explain the FOR loop with a help of a code.

565