Re: [reSIProcate] 'this' : used in base member initializer list
- From: Alan Hawrylyshen <alan@xxxxxxxxxx>
- Date: Mon, 13 Sep 2004 11:32:24 -0400
On Sep 13, 2004, at 11:17, Scott Godin wrote:
Derek,
[snip]
'this' : used in base member initializer list
The this pointer is valid only within nonstatic member functions. It
cannot be used in the initializer list for a base class.
The base-class constructors and class member constructors are called
before this constructor. In effect, you've passed a pointer to an
unconstructed object to another constructor. If those other
constructors access any members or call member functions on this, the
result will be undefined. You should using the this pointer until all
construction has completed.
Scott;
If we are doing anything other than storing the value of the this
pointer, then the code as written in non-portable and not language
compliant -- in other words -- I think it merits looking at what's
going on and refactoring it.
Alan
a l a n a t j a s o m i d o t c o m