#include<iostream>
#include<string>
using namespace std;
//定义结构体
struct Student {
string name;
int age;
int score;
};
struct Teacher {
string name;
int id;
int age;
struct Student s;
};
int main() {
struct Teacher t1;
t1.name = "张大";
t1.id = 1000;
t1.age = 31;
t1.s.name = "王二";
t1.s.age = 13;
t1.s.score = 67;
cout << "老师姓名:" << t1.name << "学生分数:" << t1.s.score << endl;
system("pause");
return 0;
}
结构体嵌套结构体
最新推荐文章于 2024-08-12 16:55:46 发布