I have such code:
#include <iostream>
using namespace std;
class X
{
int a;
public:
X()
{
cout<<"X constructor was called"<<endl;
}
X(int n)
{
cout<<"X(int) constructor was called"<<endl;
}
~X(){cout<<"X dectructor was called"<<endl;}
};
int main()
{
X x(3);
system("PAUSE");
return 0;
}
The result of this code execution is: X(int) constructor was called . But why the destructor message have not been printed?
As I understand, we create object x by calling constructor X(int) and in the end of the program this object have to be deleted, but it did not.