#include using namespace std; class ctest { public: string id; ctest() { cout << "Default constructor called\n"; id = "Made by default"; } ctest(int val) { cout << "Parameterized constructor for int called, val = " << val << endl; id = to_string(val); } ctest(string val) { cout << "Parameterized contructor for string called, val = " << val << endl; id = val; } ctest(const ctest& other){ cout << "Copy constructor called, other.id = " << other.id << endl; id = other.id; } void operator=(const ctest& other){ cout << "= called, for id = " << id << " other.id = " << other.id << endl; id = other.id; } ~ctest(){ cout << "Destructor called, id = " << id << endl; } }; void f1(const ctest& P){ cout << "Called f1 with P.id = " << P.id << endl; } ctest make_ct(string val){ ctest local_ct(val); ctest other_local_ct(val + val); cout << "&local_ct = " << &local_ct << endl; return local_ct; } int main(){ ctest G = make_ct("Gorilla"); cout << "&G = " << &G << endl; ctest A; ctest B(5); ctest C("Caterpillar"); ctest D(B); D = C; ctest E = C; ctest F("Finch"); f1(F); return 0; }