Possible Duplicate:
A function-definition is not allowed here before ‘{’
I would like to share this bug I did in my code, one of the hard to find ones:
#include <iostream>
void StartNuclearWar() {
std::cout << "War in progress..." << std::endl;
}
int main()
{
int a = 0;
// Get activation codes from C:\codes\
a = 1;
if(a == 0) {
StartNuclearWar();
}
}
Where is it?
The bug is in the comment: for us the final \ character represents a directory, for the compiler it means that the following line is part of the current line.
Of course every developer knows that, but in this case this detail is quite well hidden.