Take a look at this code, why will it not display "CleanUP" after it exits Main? I have tried writting it many different ways. Simple code, unexpected results?

Initialize
HelloWorld.......No Clean Up?

#include <iostream>
using namespace std;
class display
{
public:
display() { cout << "Initialize\n"; }
~display() { cout << "Clean up\n"; }
};
display d;

int main()
{
cout <<"Hello World!\n";
cin.get();
return 0;
}

it does print CleanUP; try it from the command line in a terminal.
instead of (double) clicking the executable.

I'm concerned that you've been here for a while now, and you still haven't figured out this CODE tags deal.

I'm using Bloodshed C++ compiler, I am starting to think it's a compiler issue. But I compiled it using Vis C++, no deals?

I'm using Bloodshed C++ compiler, I am starting to think it's a compiler issue. But I compiled it using Vis C++, no deals?

whatever you are using, if it does not cause the destructor of statics to be called (unless abort() was called), it is not a C++ compiler. the probable reason though, is that the window is disappearing too fast for you to make out what is going on.

That is why I'm using CIN.GET() so I can see what's being output to the screen.

That is why I'm using CIN.GET() so I can see what's being output to the screen.

cin.get() is inside main; destructors of statics are called (in reverse order of construction) after main returns (or exit is called). put your cin.get() as the last statement in your destructor (if that is the way you want to make a window stay).

Awesome, thanks it worked. To think I never thought of doing that? That's why I love this forum and can't wait to to become a better programmer, so I can help others.
Thanx Vijayan

great. and perhaps you could start calling a destructor a destructor (not a deconstructor).

Unrelated to your answer, but some knowledge you should know....

There's no such thing as a deconstructor in C++. Only Constructors and Destructor :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.