Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C++ > Initialising cl...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 8 Topic 44451 of 48002
Post > Topic >>

Initialising cl***** with pointers to this

by pauldepstein@[EMAIL PROTECTED] Apr 6, 2008 at 07:53 PM

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
 




 8 Posts in Topic:
Initialising classes with pointers to this
pauldepstein@[EMAIL PROTE  2008-04-06 19:53:09 
Re: Initialising classes with pointers to this
Craig Scott <audiofana  2008-04-06 20:22:03 
Re: Initialising classes with pointers to this
"Christopher Pisz&qu  2008-04-06 22:22:49 
Re: Initialising classes with pointers to this
=?ISO-8859-15?Q?Marcel_M=  2008-04-07 09:49:30 
Re: Initialising classes with pointers to this
"Christopher Pisz&qu  2008-04-08 02:22:44 
Re: Initialising classes with pointers to this
Craig Scott <audiofana  2008-04-06 20:50:53 
Re: Initialising classes with pointers to this
Craig Scott <audiofana  2008-04-08 14:04:58 
Re: Initialising classes with pointers to this
Craig Scott <audiofana  2008-04-08 14:27:29 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sun Oct 12 14:17:21 CDT 2008.