我有一个父虚拟类(及其子类,但这些不是问题)
//---------------------------------------------------------------------
class TPowerComponent
{
public :
int X, Y, Rotation;
__fastcall TPowerComponent( PowSymbType AType );
__fastcall TPowerComponent( TStream& S );
virtual void __fastcall Store( TStream& S );
__fastcall ~TPowerComponent();
virtual void __fastcall Paint(TCanvas * Canvas, const WorkSheetInfoRec& WSInfo); // se dessine
};
其中一个方法(paint)使用WorkSheetInfoRec结构,该结构由上面定义:
struct WorkSheetInfoRec {
int WSOpt, Study;
std::list<TPowerComponent*> NetWorkList;
};
问题是这个结构使用了一个父类的objectz列表,它有一个方法(paint),它也引用了一个使用列表的结构... 因此编译失败,因为每个必须在另一个之前声明。 我怎样才能在头文件中处理它。
由于
答案 0 :(得分:8)
使用前瞻声明:
class TPowerComponent;
struct WorkSheetInfoRec {
int WSOpt, Study;
std::list<TPowerComponent*> NetWorkList;
};