在C语言中因为在声明结构体时struct不能省略
例
struct Student{//定义结构体
int age;
int grade;
}
struct Student s1;
此时可以在定义结构体时加上typedef
typedf struct Student{//定义结构体
int age;
int grade;
}stu;
stu s1=NULL;
此时加上typedf,stu就相当于struct Student
所以stu s1就相当于 struct Student s1;
在C++中声明结构体时typedf可以省略
struct Student{//定义结构体
int age;
int grade;
}
Student s1;//声明结构体
也可以用这种形式
struct Student{//定义结构体
int age;
int grade;
}s1;
此时s1相当于
struct Student s1;