我有一个循环依赖问题。我有两个头文件,它们相互依赖。我遇到的问题与命名空间中的类有关。
文件 #1
class Player; // This is how I forward declare another class
namespace sef {
class Base
{
public:
Player a;
bool SendEvent(int eventType);
};
class Sub: public Base
{
protected:
Player b;
bool Execute(string a);
};
}
文件 #2
//class sef::Sub; // I am having trouble compiling this
class Player
{
public:
sef::Sub* engine; // I am having trouble compiling this
};
如何在文件#2 中转发声明 sef::Sub 类?