struct person {
string name;
string gender;
int age;
int height;
int weight;
};
結尾必須有分號!
宣告、給定值
person A;
A.name = "Billy"
A.age = 42;
"." 代表存取成員變數
結構即變數
person people[100];
people[0].name = "Billy";
struct dept {
char name[100];
int college;
person students[100];
person professors[100];
};
struct university {
char name[100];
dept depts[100];
};
university NTU;
university DYU;
NTU = DYU;
初始值
struct dept {
dept(): name("Philosophy"), college(1) {}
string name;
int college;
person students[100];
person professors[100];
};