C++结构体再学心得

自己定义一个结构体,使用struct关键字

struct student

{

  char name[20];

  int age;

  int num;

};

定义好结构体,student就相当于变量类型,我们可以直接用来定义一个student类型的变量:

student A;

也可以直接在定义结构体的时候直接进行定义变量:

struct student

{

  char name[20];

  int age;

  int num;

}A;

这个结构体可以通过sizeof(student)来获得变量类型所占用的诶村大小

结构体成员的引用形式:

结构变量名.成员名,例如:A.age=20;

原文地址:https://www.cnblogs.com/SeawinLong/p/3731242.html