当前位置:网站首页>[Error] invalid use of incomplete type 使用了未定义的类型
[Error] invalid use of incomplete type 使用了未定义的类型
2022-06-13 00:16:00 【SZU治愈系BUG】
今天在写奥特曼打大怪兽的时候,发现一个奇怪的问题,我定义了两个基类Ultraman和Monster,一个Monster的子类Boss,然后两个基类是有相互勾结的地方,它们都或多或少的使用了对方的类型进行定义自己,然后我在第一个类实现前面进行了另一个类的声明:
之后编译报错:
然后它说不能使用不完整的类类型:
我就开始犯迷糊了,明明我两个类定义的好好的,咋就说我没有定义呢。我也在前面声明了。
然后经过我和另一个大三的学长两个人两个小时的寻找,各种排查,终于意识到一个问题:
因为这两个类是相互勾结了,所以其中一个类在使用另一个类进行对象实例化的时候,另一个类也会去找这个类对象实例化,而它们都还没有定义,简单来说就是,我需要你帮我做一件事A,但是你为了做事A需要我做事B,而我做事B必须建立在你帮我做事A的前提下。
于是找到一个解决办法:
类定义和类实现分离。
类实现写在两个类定义之后。
搞定了。
边栏推荐
- PMP test experience
- Real time preview of PHP in browser by vscade
- Several interview questions in TCP three grips and four swings
- 【HCIE论述】组播IGMP-A
- 3、 Storage system
- PMP test difficulty and pass rate
- 启牛商学院里面的券商账户是安全的吗?开户费率低吗
- Go custom collation
- Why study PMP?
- Tsinghua Bosch joint ml center, thbi lab:cheng Yang Ying | realize safety reinforcement learning through the value at risk of constraints
猜你喜欢
Accelerating with Dali modules
[vscode]todo tree a to-do plug-in
63. 不同路径 II
Can branches sign labor contracts with employees
Pytorch loading model error resolution
Learn to divide subnets in an article
【Matlab】矩阵变换与矩阵求值
Leaflet that supports canvas Path. Dashflow dynamic flow direction line
Is the newly graduated college student taking BEC or PMP? PM who wants to transfer to another job in the future
What can PMP bring to you
随机推荐
[matlab] basic knowledge
[matlab] basic operation
Why study PMP?
Is the newly graduated college student taking BEC or PMP? PM who wants to transfer to another job in the future
Pipelines in go concurrency mode
The whole process from entering URL to displaying page (interview)
March 11, 2022 diary: Mr. Wang's spring, strange template mode
2022 constructor - Equipment direction - General Foundation (constructor) operation certificate examination questions and simulation examination
Video tracker error troubleshooting
PLC can also make small games ----- CoDeSys can write small games of guessing numbers
Use of split() method in string class
New blog address
What are the PMP scores?
VHDL programming experiment exercises collection
63. 不同路径 II
[matlab] matrix transformation and matrix evaluation
Accelerating with Dali modules
PMP test experience
【Matlab】二维曲线
The PMP examination time in March 2022 is set -- "March 27"