In C++, #define has global scope. If you have a #define FAIL (-1) in a header file that you include, you cannot declare a variable named FAIL anywhere else, not even inside a namespace. If you do, you will get the cryptic error message "expected an identifier":
So, don't use define for named constants in C++, use const int etc. If you are using C instead of C++, read this.
No comments:
Post a Comment