例题7.1 声明学生结构体Student
定义两个结构体变量student1和student2
成员包括学号 姓名 性别 出生日期 成绩
学生1初始化
把学生1复制给学生2
输出学生2
1 #include<iostream> 2 #include <string.h> 3 using namespace std; 4 struct date{ 5 int year; 6 int month; 7 int day; 8 }; 9 struct student{ 10 int num; 11 string name; 12 date jibenn; 13 char sex; 14 float score;} 15 student1={164643131,"yukino",1997,4,84,'girl',85},student2; 16 int main(){ 17 student2=student1; 18 cout<<student2.num<<endl; 19 cout<<student2.name<<endl; 20 cout<<student2.jibenn.year<<endl; 21 cout<<student2.jibenn.month<<endl; 22 cout<<student2.jibenn.day<<endl; 23 cout<<student2.sex<<endl; 24 cout<<student2.score<<endl; 25 }