在包含该类列表的结构后定义的C 类

C++ class defined after a struct that contains a list of that class

本文关键字:定义 结构 列表 包含该      更新时间:2023-10-16

我有一个父级虚拟类(及其孩子,但这不是问题)

//---------------------------------------------------------------------
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
};

其方法之一(油漆)使用工作表inforec结构,该结构在上面定义:

struct WorkSheetInfoRec {
    int WSOpt, Study;
    std::list<TPowerComponent*> NetWorkList;
};

问题在于,该结构使用的objectz列表是父母的,该类别具有一种方法(paint),该方法也指的是使用列表的结构...因此,汇编失败了,因为必须在另一个之前声明每个汇编。我该如何在标题文件中处理。

谢谢

使用前向声明:

class TPowerComponent;
struct WorkSheetInfoRec {
    int WSOpt, Study;
    std::list<TPowerComponent*> NetWorkList;
};