Edit: Sorry if I did not specify, I can NOT change these given structs and classes. So I can not make get/set functions for the fields in the Student struct and Grade class.
This is an assignment of two parts, part 1 was relatively easy and has a struct like so:
Part1 (Student.h) Can NOT be changed
const unsigned int MAX_GRADES= 5;
struct Student
{
char* studentText;
unsigned int numSubjects;
Grade grades[MAX_ANSWERS];
Student():studentText(0){};
~Student();
};
Then in part 2 that has changed to:
Part2 (Student.h) Can NOT be changed
struct Student
{
static const unsigned int MAX_GRADES = 5;
Student():studentText(0){;}
Student(char*,unsigned int,Grade*);
Student(Student&);
~Student();
friend ostream& operator<<(ostream&,Student&);
private:
char* studentText;
unsigned int numSubjects;
Grade grades[MAX_GRADES];
};
Grade is a class with also private string:
Part2 (Grade.h) Can NOT be changed
class Grade
{
char* subject;
bool pass;
public:
Grade():subject(0){;}
Grade(char*,bool);
Grade(Grade&);
~Grade();
Grade& operator=(Grade&);
friend ostream& operator<<(ostream&,Grade&);
};
The variable studentText that I used to use to check if a Student is empty inside students[] by using:
if(students[j]->studentText==0)
Has now become private and I can not reach it from my main. Can anyone point me to the right direction.
Can I use the overloaded << to somehow get studentText and test if it is 0.
Thanks in advance
Aucun commentaire:
Enregistrer un commentaire