A simple program that consists of a class with a constructor and a destructor. - C++ Class

C++ examples for Class:Destructor

Description

A simple program that consists of a class with a constructor and a destructor.

Demo Code

#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;
}

Result


Related Tutorials