"Bryan Bullard" <th********************@sbcglobal.net> wrote...
"Karl Heinz Buchegger" <kb******@gascad.at> wrote in message
news:40***************@gascad.at...
What is your specific problem in understanding. There is nothing
mystical about a copy constructor. It's just a constructor which takes a
reference to an object of the same type as an argument. Just like all constructors
with arguments it means: initialize the new object by using the passed
argument to do so. Whatever initialization in your specific case may
mean. is it true that when the copy constructor is used, no other constructor is
called?
also, i'm a little confused about what should go in the copy constructor
and the overridden assignment operator.
A compiler-generated copy constructor invokes copy construction semantics
for all base classes and members (that's to the question about "no other
constructor"). So far there is no mechanism in the language to invoke
other constructors for the same object.
Assignment operator is not involved during construction. It's called for
assignment expressions. The difference between the two is not dramatic,
but still significant, I believe. When construction is happening, the
object is fresh, new, nothing has been previously constructed or used.
When assignment is happening, the object has its previous state and needs
to account for that (dispose of the "old" assets before acquiring "new"
ones, so to speak). Did you read about "rule of three" as I recommended?
V