what destructor used for in c++
deallocate and clean up c++ object and class member after get destroyed
c++ destructor
class House { private: std::string location; int rooms; public: // Constructor with default parameters House(std::string loc = "New York", int num = 5) { location = loc; rooms = num; } void summary() { std::cout << location << " house with " << rooms << " rooms.\n"; } // Destructor ~House() { std::cout << "Moved away from " << location; } };
Source: www.codecademy.com
c++ destructor
Moved away from New York
Source: www.codecademy.com