Posted by M. Heffner on April 06, 2001 at 01:03:50:
In Reply to: Re: Questions on latest homework answers posted by Daniel Longest on April 06, 2001 at 00:13:40:
: Stroustrup in Section 10.4.6 says "The members' constructors are called before the body of the containing class' own constructor is executed." To me this says that you can use the initialization list to initialize the subobjects before the body of the constructor is executed (or the object is constructed the rest of the way).
Then you're misinterpreting what Stroustrup is trying to say. You can
use the the member initializer list to call a specific constructor of
a sub-object or you can explicitly call the default constructor. Or
(as illustrated with the second example under $10.4.6) instead of
explicitly calling the default constructor, you can omit the member
from the initializer list and the default constructor will be called
automatically. In any case, ALL the sub-objects are ALWAYS constructed
before the start of the constructor body of the outer class.
Anyways, enough of this discussion on this board, followup by email if
Post a Followup