As mentioned in the title. The following code shows the error:
#include <iostream> using namespace std; class link { public: link() { num=0; next=NULL; } int num; link* next; }; int main() { link test; return 0; }
compile this code with
g++ test.cpp -o test
my g ++ versions
g ++ (Ubuntu / Linaro 4.6.3-1ubuntu5) 4.6.3
And the compiler shows the following error
test.cpp: In function 'int main()': test.cpp:18:10: error: expected ';' before 'test'
If I comment on this 'link test' statement, then everything will be fine. In addition, if I replace the โlinkโ with another name, for example, โLinkโ, everything is fine too.
In Visual Studio or VC, the code is fine ... So that really confused me.
source share