嵌套结构|我应该在主体结构中再次声明“ struct”吗?

如您所见,两个代码几乎相同,不同之处在于,在我编写数据类型的第一个代码中,我的意思是,我在“ directionInfo”之前写了“ struct ” employeeDirection; ”。

在第二个代码中我没有,但是它仍然有效,并且我不知道是否在不写数据类型的情况下使用它是否正确。

以下是带有“ struct

的代码
struct directionInfo
{
    string direction;
    string city;
    string state;
};

struct employees
{
    string name;
    struct directionInfo employeeDirection;
    double salary;
}employee[2];

以下是不含“ 结构

的代码
struct directionInfo
{
    string direction;
    string city;
    string state;
};

struct employees
{
    string name;
    directionInfo employeeDirection;
    double salary;
}employee[2];

您能告诉我两种方法是否正确吗? 谢谢!

qiulu_0618 回答:嵌套结构|我应该在主体结构中再次声明“ struct”吗?

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3133502.html

大家都在问