On 28 Jun., 13:27, Tim Frink <plfr...@yahoo.de> wrote:
> Hi,
>
> I've two questions on constructors:
>
> 1) Is the order in which class member are initialized
> within the constructor crucial? So, do I have to preserve
> the order in which class member have been declared in the header
> file also for the constructor initializations?
The order of initialisation will be in order of declaration (with base-
classes initialised first from left to right unless the base-class is
virtual). The order is therefore determined by the declaration and
good code would always follow that order.
>
> 2) Must STL containers like "list<ClassA*> mList" which I
> declare in the header file be also initialized in the
> constructor?
Yes, but it always will be. If you say nothing explicitly about mList
in the initialiser list, mLists default constructor will be called
(creating an empty list), just as for any other member or base-class.
/Peter
|