Consider a simple program in C++:
#include <开发者_JAVA百科;iostream>
class link {};
int main() {
link alink;
}
Compiling it with g++ (Ubuntu/Linaro 4.5.2-8ubuntu4) 4.5.2 gives the following error:
test.cpp:6:8: error: expected ‘;’ before ‘alink’
Why do I get this error?
Because link is also a posix function and the function name hides the class name.
You can say class link alink;
but better put your class into a new namespace or rename it.
精彩评论