Its funny how I post the question and went to find out the answer myself. Apparently I had some great finding at least to me.
Here's my code.
#include "stdafx.h"#include <iostream>class A{public: A() { std::cout << "A constructor is called" << std::endl; } ~A() { std::cout << "A destructor is called" << std::endl; }};class B{public: B( int i ) { std::cout << "B constructor is called with i = " << i << std::endl; } ~B() { std::cout << "B destructor is called" << std::endl; }};class C{public: C() : m_B( 0 ) , m_A() { std::cout << "C constructor is called" << std::endl; } ~C() { std::cout << "C destructor is called" << std::endl; }private: A m_A; B m_B;};int _tmain(int argc, _TCHAR* argv[]){ C * c = new C(); delete c; int i; std::cin >> i; return 0;}
Here's the result
A constructor is called
B constructor is called with i = 0
C constructor is called
C destructor is called
B destructor is called
A destructor is called
Apparently, my assumption is correct. :)
The interesting things is that the order of the constructors and destructors being called. The initialization part of the C constructor doesn't affect the order. It is the order you declare your variables in the class that dictate the order of the constructor being called.
This was tested on Visual Studio .NET 2005 so behavior may varies. :)
I think I learnt something today. Sorry for this self answered post. :X