Hi :)
I am having troubles making a program which works in the following way:
We have a class made up of 4 students who have passed 5 exams.
I have to create two classes, one called "students" which has an array made up of the 5 exams, and a class "exams" in which we can insert (and read) the grade and the date of the exam.
So, for the student1, we have:
exam1(grade,day,month,year)
exam2 (same...)
...
student2
same.
What i have done so far is to make the class "exam" in this way:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
|
#include <iostream>
using namespace std;
class exam {
public:
int grade;
int day;
int month;
int year;
void set_values (int,int,int,int);
};
void exam::set_values (int x, int y, int z, int w)
{
grade=x;
day=y;
month=z;
year=w;
}
int main () {
exam exam1;
exam1.set_values (30,24,02,2014);
cout << "Exam 1: grade " << exam1.grade << " passed on the " << exam1.day<<"/"<<exam1.month<<"/"<<exam1.year << endl;
}
|
I would like to have some help, and maybe an example, of how i can link this class to the one student, in the way i have explained. Thanks in advance.