#include <iostream>

namespace A {
	namespace B {
		struct C {
			struct D {
                int e;	// variable e lifetime is same with struct D lifetime. Available only within struct D initialized
                D() : e(42) {}
			} d;	// variable d lifetime is samw with C struct lifetime. Available only within struct C initialized
			C() {}
			C(int v) {
				d.e = v;
			}
		} c;	// variable c lifetime is entire program. Scope is A::B::c
	}
}

int main() {
	// access variable with program lifetime in A::B namespace
	std::cout << A::B::c.d.e << std::endl;
	
	// create local variable of type A::B::C and access its fields
	A::B::C myc(55);
	std::cout << myc.d.e << std::endl;
	
	// declare struct F within main function scope and access its fields
	struct F {
		int g;
		F(int v) : g(v) { }
	} f (100);
	std::cout << f.g << std::endl;
	
	return 0;
}