Here are two possibilities for you to explore:
1 - Your "TheWorld" object is global; there is no guarantee that std::cout is constructed before TheWorld. Test this by putting the instantiation of this object inside "main()".
2 - std::cout is not automatically flushed, so the output may be stuck in a buffer when system("pause") is called. Try flushing cout by adding "<< endl" to your code, e.g.,
std::cout << "Hello!" << std::endl;
std::cout << x << std::endl;
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Recently downloaded dev-cpp v. 4.9.7.0
Here is the code that I'm trying to 'debug'
#include <iostream>
#include <stdlib.h>
class World
{
public:
World () { std::cout << "Hello!\n"; }
~World () { std::cout << "Good bye!\n"; }
};
World TheWorld;
int main()
{
int x;
x = 3;
std::cout << x;
system("PAUSE");
return 0;
}
As you can see there are three outputs. None of them work in the debug mode (the screen stays blank). Any ideas?
Btw debug doesn't work unless you put "-g" in the debug options.
Here are two possibilities for you to explore:
1 - Your "TheWorld" object is global; there is no guarantee that std::cout is constructed before TheWorld. Test this by putting the instantiation of this object inside "main()".
2 - std::cout is not automatically flushed, so the output may be stuck in a buffer when system("pause") is called. Try flushing cout by adding "<< endl" to your code, e.g.,
std::cout << "Hello!" << std::endl;
std::cout << x << std::endl;
Thank you for the "-g" tid-bit!
I have been going nuts trying to get debug to work!
Thank you again.