Posted by Daniel Longest on April 06, 2001 at 13:12:41:
In Reply to: Re: Questions on latest homework answers posted by leon gunden on April 06, 2001 at 12:11:29:
Since I can't seem to let it go, I'll just say one more thing. I agree, there is a difference between initialization and construction. However, if you wish to construct a subobject with values using its constructor, pretty much the only way to do so is to do it in the init list. This is the same effect as invoking the constructor, be it parameterized or default. If you do not do this explicitly, it will be done implicitly before the constructor body executes. In either case, when the ctor body is reached, the subobject will be fully constructed. If you then use mutators to change its value, we're no longer talking about construction vs. initialization because it's constructed and initilaized. I think at this point we're arguing over the choice of wording, that the init list constructs the object versus it initializes it. The init list does initialize the subobject with values, but it does that by constructing it, IMO. That is the only way to "initialize" an object, by invoking its constructor. That's about all I have to say on the matter so I think that will be my last post on the matter.
: Obviously this thread has gone on quite long enough. But I can't seem to let this go. What you said above is correct, and I agree with you. However the question didn't say anything about initialization. It was talking about construction. There is a difference, as any self respecting C/C++ programmer should know. The purpose of the initializer list is to *initialize* the the base objects before the encapsulating object's constructor is invoked, not to *construct* the base objects. You can construct a pointer, or a built in type without initializing it. Perhaps I should have inferred the question was asking about initialization but that is not what the question said. Lets let this rest now. I can argue this point forever, but what it comes down to is that the question was worded incorrectly (it meant one thing and said another). Sorry to clutter up the message board with this garbage.
Post a Followup