You are creating an extra global instance c
here:
class cls1
{
int x; cls xx;
public:
cls1(int i=0){cout<<" c2 ";x=i;}
~cls1(){cout<<" d2 ";}
} c; // <-- here
That one is created first.
Otherwise your expected order is spot-on.
2
solved C++ Constructor Oder [closed]