#include <iostream>
using namespace std;

struct M1 {
int m_i; 
M1 (int i) : m_i(i) { cout<<"ctor M1 "<<m_i<<"\n"; }
};

struct M2 {
int m_o; 	
M2 (M1 &m) :m_o(m.m_i) { cout<<"ctor M2 "<<m_o<<"\n"; }
};

class A {
	M1 m1; 
	M2 m2; 
public: 
	A(int i) : m2(m1), m1(i) { cout << "ctor A\n"; }
};
class B {
	M2 m2; 
	M1 m1; 
public: 
	B(int i) : m1(i), m2(m1)  { cout << "ctor B\n"; }
};
int main() {
	cout << "If members are declared in the right order: the initialisation is as expected\n";
	A(1); 
	cout << "If members are declared in the wrong order: the dependent element is constructed based on wrong value\n";
	B(2); 
	// your code goes here
	return 0;
}