invalid use of incomplete type struct 或者是class的解决办法

问题一:invalid use of incomplete type

出现这个问题,表明编译器不知道所用的struct 或者是class的具体实现,通常出现在如下情况:假设我们有一个class some定义在some.h中,实现在some.cpp中,我们在other.cpp中要用到这个some 的方法,于是我们再other.h中声明可一个class some,并声明了要用到的方法,这样就会导致上述的问题,解决这个问题的方法是:在other.cpp中include some.h,这样编译器就会根据该头文件找到class some的具体定义,问题也就解决了。

猜你喜欢

转载自my.oschina.net/u/3045933/blog/875393