#include #include #include using namespace std; class ThingT { public: ThingT (string t = "none") : title{t}, id {count++} { cout << "Item " << id << " constructor with title " << title << endl; } ~ThingT() { cout << "Item " << id << " destructor with title " << title << endl; } private: string title; inline static int count{0}; // silly value, should never see this. int id{-1}; }; class BigThingT { public: BigThingT(): t1{"P1"}, t2{"P2"} { cout << "A big thing constructor" << endl; } ~BigThingT() { cout << "A big thing destructor" << endl; } private: ThingT t1, t2; }; int main() { cout << "Before the items are declared " << endl << endl; cout << "Declaring a single thing " << endl ; ThingT a("first"); cout << endl; cout << "Building a vector of things " << endl; vector things(1); cout << "Push 1 " << endl; things.push_back(ThingT("second")); cout << endl; cout << "Push 2 " << endl; things.push_back(ThingT("third")); cout << endl; cout << "Push 3 " << endl; things.push_back(ThingT("fourth")); cout << endl; cout << "Buiding a bigThing " << endl; BigThingT bt; cout << endl << endl; cout << "Build a sub block" << endl; { ThingT e{"In the block"}; cout << endl; cout << "Exiting the block " << endl; } cout << "Out of the block" << endl; ThingT f{"out of the block"}; cout << endl; cout << "Exiting the program" << endl; return 0; }