t is destructed at the closing brace of main(). Chances are it was displayed, but the program exited before you chould see it. Consider the following:
1 2 3 4 5
void main()
{ test t(1);
t.print();
system ("pause");
}
At the time that "pause" is executed, t has not yet been destructed.
PLEASE USE CODE TAGS (the <> formatting button) when posting code.
It makes it easier to read your code and also easier to respond to your post. http://www.cplusplus.com/articles/jEywvCM9/
Hint: You can edit your post, highlight your code and press the <> formatting button.
int main() // <- main must return int, not void
{
{ // <- limit scope of the 'test' object
test t(1);
t.print();
} //<- t's destructor called here
// <- pause here to see destructor's message
}
Or do what computergeek said and run from a console to see the output.