P
pauldepstein
I don't understand the following line of code. Please note that, as
my naming suggests, DerivedClass is a class that is derived from
BaseClass.
virtual BaseClass* clone() const{ return new DerivedClass(*this);
My confusion arises from the fact that DerivedClass appears only to
take the default constructor, initialised with ()
So how does DerivedClass(*this) make sense when all objects of
DerivedClass are constructed via a constructor with no parameters?
I know this is a basic question about a fairly common type of c++
construct, and I'm eager to learn more.
Thanks for your help,
Paul Epstein
my naming suggests, DerivedClass is a class that is derived from
BaseClass.
virtual BaseClass* clone() const{ return new DerivedClass(*this);
My confusion arises from the fact that DerivedClass appears only to
take the default constructor, initialised with ()
So how does DerivedClass(*this) make sense when all objects of
DerivedClass are constructed via a constructor with no parameters?
I know this is a basic question about a fairly common type of c++
construct, and I'm eager to learn more.
Thanks for your help,
Paul Epstein