Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/vba/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ Can';t声明其他类的类字段类型_C++_Class - Fatal编程技术网

C++ Can';t声明其他类的类字段类型

C++ Can';t声明其他类的类字段类型,c++,class,C++,Class,为什么我不能声明其他类的类字段类型?这给了我C4430错误: //Entity.h file class Entity { public: Box test; }; class Box { public: double length; // Length of a box double breadth; // Breadth of a box double heigh

为什么我不能声明其他类的类字段类型?这给了我C4430错误:

//Entity.h file
    class Entity
    {
    public:
        Box test;
    };


    class Box
    {
    public:
        double length;   // Length of a box
        double breadth;  // Breadth of a box
        double height;   // Height of a box
    };

实体
在定义之前需要了解类
。此外,由于在
实体
类中包含
的对象而不是指向
的指针,它还需要知道
类框
的大小(需要
类的完整定义)和成员的定义(因为它将访问
框::框
,以初始化实际字段),因此,在将
作为
实体
类中的字段之前,需要对其进行完整定义

    class Box
    {
    public:
        double length;   // Length of a box
        double breadth;  // Breadth of a box
        double height;   // Height of a box
    };

    class Entity
    {
    public:
        Box test;
    };

首先定义类框,然后定义类实体。在这个序列中,类实体还不知道接下来定义了一个类框。