一般的struct结构体语法:
struct 结构体名
{
结构体成员列表
}s1,s2; //这是结构体在创建变量
并且在定义时,如下:
struct student
{
string name;
string number;
};
int main()
{
student stu1;
}
但是typedef struct结构体语法:
typedef struct student
{
string name;
string number;
}stu; //这里的stu不是在创建变量,而相当于student的别名
int main()
{
stu stu1; //定义方式
}
以下是我个人对这个语法的理解,如有不对的地方,欢迎指正!