(I'm using Visual C++ 2008) I've always heard that main() is required to return an integer, but here I didn't put in return 0;
and and it compiled with 0 errors and 0 warnings! In the debug window it says the program has exited with code 0. If this function is named anything other than main(), the compiler complains saying 'blah' must return a value. Sticking a return;
also causes the error to appear. But leaving it out completely, it compiles just fine.
#include <iostream>
using namespace std;
int main()
{
cout << "Hey look I'm supposed to return an int but I'm not gonna!
";
}
Could this be a bug in VC++?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…