C++ examples for Class:Destructor
A simple program that consists of a class with a constructor and a destructor.
#include <iostream> using namespace std; class MyClass//from w w w . j av a 2 s.c om { public: MyClass() { cout << "Constructor called!" << endl; } ~MyClass() { cout << "Destructor called!" << endl; } }; int main(int argc, char* argv[]) { MyClass myClass; cout << "Function body!" << endl; return 0; }