[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Protocols and OO-ness [was: Copy method]
From: |
Juan J. Merelo |
Subject: |
Re: Protocols and OO-ness [was: Copy method] |
Date: |
Thu, 13 Feb 1997 11:45:46 -0700 |
>>>>> ""glen" == "glen e p ropella" <address@hidden> writes:
>> This is not such a big deal in C++: copy ctors are
>> compiler-generated, if you don't bother to supply one; and they
>> should be defined in any well-behaved class. Besides, they are
>> not inherited, which forces you to supply a copy constructor,
>> or copy method, everywhere in the hierarchy.
"glen> Interesting. What do you mean "compiler-generated?"
Well, exactly that. If you don't provide an implementation of the
copy-ctor, the compiler will generate one, usually a shallow copy,
which is not probably what one intends. That means that if you
inadvertendly use a copy ctor, say, by
varType foo = bar;
the compiler will generate a call to that compiler-generated copy.
JJ
--
address@hidden