struct student//定义一个学生结构体
{
string name;
int age;
}
struct teacher
{
string name;
int age;
struct student stu;//定义学生结构体
}
int main()
{
teacher t;
t.name="老师1";
t.age=22;
t.stu.name="学生";//为学生赋值
t.stu.age=12;//为学生赋值
}
struct student//定义一个学生结构体
{
string name;
int age;
}
struct teacher
{
string name;
int age;
struct student stu;//定义学生结构体
}
int main()
{
teacher t;
t.name="老师1";
t.age=22;
t.stu.name="学生";//为学生赋值
t.stu.age=12;//为学生赋值
}