如您所见,两个代码几乎相同,不同之处在于,在我编写数据类型的第一个代码中,我的意思是,我在“ 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];
您能告诉我两种方法是否正确吗? 谢谢!