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

来源:互联网 发布:程序员要考什么证 编辑:程序博客网 时间:2024/06/06 00:07

常见问题一: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的具体定义,问题也就解决了。

0 0
原创粉丝点击