0
我声明两个类,如下面的静态实例,A是父类,B子答:父类包含子类C++
//a.h
#include "b.h"
//class B; Adding this line doesn't work
class A{
static B b;
}
//b.h
#include "a.h"
class B:public A{ // XCode error here: expected class name
}
然而,的XCode 6.1别让我编译一直在说“预期班级名称”。
实际上,我试图实现一本书中提到的状态机游戏编程模式http://gameprogrammingpatterns.com/state.html#static-states。在该书中,父状态类拥有子类的静态实例。
您的设计需要除臭剂。 – 2015-01-04 13:54:06
前向声明'class B;'很好。通知不包括。刮'#包括“b.h”' – 2015-01-04 13:57:54