class MyClass {
  public:
    int myNum;
    string myString;
    MyClass() {  // Constructor
      myNum = 0;
      myString = "";
    }
    ~MyClass() {  // Destructor
      cout << "Object destroyed." << endl;
    }
};
MyClass myObj;  // Create an object of MyClass
// Code here...
// Object is destroyed automatically when the program exits the scope
Comments