编译错误:missing type specifier - int assumed. Note: C++ does not support default-in
编译错误:
- C/C++ code
1>file1.cpp1>e:\代码\test\test\file2.hpp(8) : error C2143: syntax error : missing ')' before '*'1>e:\代码\test\test\file2.hpp(8) : error C2143: syntax error : missing ';' before '*'1>e:\代码\test\test\file2.hpp(8) : error C2460: 'B::A' : uses 'B', which is being defined1> e:\代码\test\test\file2.hpp(7) : see declaration of 'B'1>e:\代码\test\test\file2.hpp(8) : error C2059: syntax error : ')'1>e:\代码\test\test\file2.hpp(8) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int1>e:\代码\test\test\file2.hpp(8) : error C2473: 'a' : looks like a function definition, but there is no parameter list.1>e:\代码\test\test\file2.hpp(9) : error C2059: syntax error : '}'1>e:\代码\test\test\file2.hpp(9) : error C2143: syntax error : missing ';' before '}'1>e:\代码\test\test\file2.hpp(9) : error C2059: syntax error : '}'
源码:
- C/C++ code
file1.hpp文件: #include "file2.hpp" struct A { A(){}; }; file2.hpp文件 #include "file1.hpp"struct B{ B(A* a){};};最近在编码的时候突然出现了一堆类似的错误,后来去掉一个头文件后就好了,最后整理了下,大概和上述代码一样类似的错误,将file1.hpp文件中的#include "file2.hpp" 去掉后就好了。请教下,这是为什么。
[解决办法]
循环。你这样循环的定义。我想问你这个到底是A先还是B先呢??
[解决办法]
file1.hpp文件里#include "file2.hpp"完全没必要,其他地方要用时,直接#include "file2.hpp"就行了
[解决办法]