You have a number of things to consider. First, programs are designed to run to completion and terminate. If you don't want it to terminate before you can see the output, write something that requires user input. One example showed that, but it was AFTER THE RETURN, so it was never executed. Had you run the program from a command line, you would have seen the results. That's because the window is owned by the system and not by the app, so it just returns to the prompt, and doesn't close.
Code:
#include <iostream>
using std::cout;
using std::cin;
int main (int argc, char *argv [])
{
cout << "Hello, World\n";
cin.get ();
return 0;
}
With C++, don't use the old .h headers. Much of the material they reference has been deprecated. Using 'cout << "Hello, World\n";' is fine in most instances. Sometime you need to make sure the output is flushed to the screen (more complex, possibly multithreaded apps, for instance). In that case, use 'cout << "Hello, World" << endl;'.
"using namespace std;" is contraindicated in all but the most trivial programs. You are very likely to wind up generating a duplicate symbol. Either use individual using statements (using std::cout;) or fully qualify the reference (std::cout << "blah";).
In some instances, where you have required previous input, the stream will already have information in it, so the cin.get () will be satisfied and not cause a pause. In those cases, clear the stream first with cin.sync () or cin.ignore ();