构造体:
用于寄存一组类型不同数据的汇合 (collection).
struct Student
{
int num;
char name[20];
char sex;
int age;
float score;
char addr[30];
}stu[3]={{10101,″Li Lin″, ′M′, 18,87.5, ″103 Beijing Road″},
{10102,″Zhang Fun″,′M′,19,99, ″130 Shanghai Road″},
{10104,″Wang Min″,′F′, 20,78.5, ″1010 Zhongshan Road″}
};
指针
用于寄存指标变量所在内存地址的变量, 当然也能够寄存指针自身所在内存地址, 套娃.
type x;
type *var = &x;
type **var_adr = &var;
构造体指针应用
typedef struct Books {char title[50];
char author[50];
char subject[100];
string str;
int book_id;
}Books;
int main(){
Books *book1 = new Books; // 须要动态分配空间
book1->string = '须要头部引入 string 类';
book1->book_id = 1;
}