use*_*100 1 c++ dependencies class
我想在一个文件中保留两个类,我希望其中一个包含另一个文件的实例.所以在我的头文件中我有这样的东西:
class Box{
Item a,b,c;
/*
...
*/
}
class Item{
/*
...
*/
}
Run Code Online (Sandbox Code Playgroud)
显然编译器说它不知道什么Item.如何让它看到Item类?
只需在类顶部移动Item类定义即可Box.现在Box可以看到完整的Item类型,它有效成为Box的成员.
class Item{
/*
...
*/
}
class Box{
Item a,b,c;
/*
...
*/
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
115 次 |
| 最近记录: |