上代码:
#include <iostream>
#include <windows.h>
#include <string>
#include <cmath>
using namespace std;
struct Student{
string name;
int age;
string sex;
} ;
struct Teacher{
string name;
int age;
string sex;
int teachage;
};
struct defClass{
string name;
int grade;
int cla;
int wstudents;
Student studentslist[wstudents];
int teachers;
Teacher techerslist[teachers];
};
int main(){
defClass p;
Student st1={"张三",12,"男"};
Student st2={"李四",11,"男"};
p.wstudents=2;
p.studentslist{st1,st2};
cout<<p.studentslist[1].age<<endl;
return 0;
}
报错:
程序目的:声明defClass,Student,Teacher变量类型并创建defClass类,输出类中学生信息