如何创建等级类变量的数组。我不明白如何初始化和写什么main()
。由此,有没有办法使常数?我需要一个 for 循环来读取和输出数组吗?谢谢
class First
{
public:
int getId();
void setId(int);
int getExam();
void setExam(int);
void print();
First(int studentId, int exam);
private:
int id;
int grade;
};
int main()
{
int studentId = 0;
int exam = 0;
First Student(studentId, exam);
cout << "Enter student id" << endl;
cin >> studentId;
Student.setId(studentId);
cout << "enter grade" << endl;
cin >> exam;
Student.setExam(exam);
Student.print();
return 0;
}