1#include <iostream> 2#include <string> 3 4struct baz 5 { 6 int h; 7 int k; 8 baz(int a, int b) : h(a), k(b) {} 9 }; 10 11struct bar 12 { 13 int i; 14 int* i_ptr; 15 baz b; 16 baz& b_ref; 17 bar(int x) : i(x),i_ptr(new int(x+1)),b(i+3,i+5),b_ref(b) {} 18 }; 19 20struct foo 21 { 22 int a; 23 int* a_ptr; 24 bar b; 25 26 foo(int x) : a(x), 27 a_ptr(new int(x+1)), 28 b(2*x) {} 29 30 }; 31 32int main(int argc, char** argv) 33{ 34 foo foo1(12); 35 foo foo2(121); 36 37 foo2.a = 7777; // Stop here 38 *(foo2.b.i_ptr) = 8888; 39 foo2.b.b.h = 9999; 40 41 *(foo1.a_ptr) = 9999; 42 foo1.b.i = 9999; 43 44 int numbers[5] = {1,2,3,4,5}; 45 46 return 0; 47 48}