when is a class destructor called c++ code example
Example 1: cpp class constructor
class MyClass { // The class
public: // Access specifier
MyClass() { // Constructor
cout << "Hello World!";
}
};
Example 2: c++ clas deconstructor
class Line {
public:
Line(); // This is the constructor declaration
~Line(); // This is the destructor: declaration
};