I have the following code in a header file:
enum {false,true};
and I have my main function in main.c. if I change the extention to main.cpp I get the following error:
Error C2059: syntax error 'constant'
Im using visual c++, any Idea why`?
I have the following code in a header file:
enum {false,true};
and I have my main function in main.c. if I change the extention to main.cpp I get the following error:
Error C2059: syntax error 'constant'
Im using visual c++, any Idea why`?
true
and false
are keywords representing constant values in C++. You cannot use them to name things such as enum values.
As an example, the following would compile
enum { false_, true_ };
int main() {}
false
and true
are reserve words in C++. You can't redefine it as variable.