#include #include using namespace std; class SmallObj{ public: SmallObj(string n="default"):name(n) { cout << "\tA SmallObj called " << name << " was created " << endl; } ~SmallObj() { cout << "\tA SmallObj called " << name << " is going away." << endl; } private: string name; }; class BigObj { public: BigObj(string n="default"): name(n),a(name+"-a"),b(name+"-b"),c(name+"-c"){ cout << "A BigObj called " << name << " was created." << endl; }; ~BigObj() { cout << "A BigObj called " << name << " is going away." << endl; } private: string name; SmallObj a; SmallObj b; SmallObj c; }; int main() { //SmallObj x; //SmallObj y("Y? Because we like you!"); cout << "Pre Declaration" << endl << endl; BigObj first("first"); //BigObj second("second"); cout << endl << "in the body " << endl << endl; return 0; }