066.结构体-结构图嵌套结构体
#include <iostream> using namespace std; //定义学生结构体 struct student { string name; int age; int score; }; //定义老师结构体 struct teacher { int id; string name; int age; struct student stu; }; int main() { //结构体使用 teacher t; t.id = 1000; t.age = 100; t.name = "老刘"; t.stu.age = 50; t.stu.name = "小李"; t.stu.score = 500; cout << "老师名字:" << t.name << "老师编号:" << t.id << "老师年龄:" << t.age << "老师辅导学生姓名:" << t.stu.name << "学生年龄:" << t.stu.age << "学生分数:" << t.stu.score << endl; system("pause"); return 0; }