1

can you tell me in which order the member variables of an object are initialized (constructor calls) and if the initialization list has an influence on it? For example if I instantiate:

 class Meta
 {

 public:
    Meta() : a(), b(),c(),d()
    {

    }

 private:

    SomeObject d;
    SomeObject c;
    SomeObject b;
    SomeObject a;
 };

Would the member variables be initialized in the order a,b,c,d ( as in the initialization list) or d,c,b,a (the order in which they are defined in the class) ? I'm experimenting with Visual Studio 2012 Debugger and my tests suggest the latter, but I'd like to know if I can influence it via the initialization list.

Regards

user5024425
  • 397
  • 3
  • 14

1 Answers1

3

They're done in the order they're declared in, irrespective of the initializer list.

Colin
  • 3,394
  • 1
  • 21
  • 29