C++ Errors: “ 'class' does not name a type” and “invalid use of incomplete type ‘struct …' ”
- 阅读更多 关于 C++ Errors: “ 'class' does not name a type” and “invalid use of incomplete type ‘struct …' ”
问题 Here is a very repetitive issue, also here in StackOverflow, but I do not manage to solve my problem even trying the different answers. So, I have some classes: main.cpp: #include "foo.h" #include "bar.h" ... foo.h: #include "bar.h" class foo { foo(); bar& bind(bar &b); gru& bind(gru &g); }; bar.h: #include "foo.h" class bar { bar(); foo& bind(foo &f); gru& bind(gru &g); }; Clearly, I have a cyclic dependency. So I get the infamous error 'bar' does not name a type . In this case, I add class