#include using namespace std; class MyClass { private: int field; public: MyClass(int f) : field(f) { cout << "MyClass constructor called: field = " << field << endl; } ~MyClass() { cout << "MyClass destructor called: field = " << field << endl; } }; void test() { cout << endl << "Automatic allocation on the runtime stack:" << endl; MyClass mc(11); cout << endl << "Dynamic allocation:" << endl; MyClass *mcp = new MyClass(12); cout << endl << "Explicit deletion of dynamically allocated object:" << endl; delete(mcp); cout << endl << "Automatic deallocation when going out of scope:" << endl; } int main() { test(); }