So I was trying implement a particular class with this declaration:
class Student
{
public:
Student ();
Student (int, int);
~Student ();
void setMod (int, int);
void setId (int);
void setScore (int);
int getId () const;
int getScore () const;
void print () const;
private:
int idNo, score, mod;
};
Student::Student ()
{
idNo = -999;
score = -999;
}
Student::Student (int idNo, int score)
{
this -> idNo = idNo;
this -> score = score;
}
Student::~Student ()
{
static int i = 0;
}
void Student::setMod (int idNo, int size)
{
this -> mod = idNo % size;
}
void Student::setId (int idNo)
{
this -> idNo = idNo;
}
void Student::setScore (int score)
{
this -> score = score;
}
int Student::getId () const
{
return idNo;
}
int Student::getScore () const
{
return score;
}
void Student::print () const
{
cout << idNo << "\t\t" << mod << "\t" << score << endl;
}
And then I have problem with these implementation:
1.
if (table [k].getId () == -999)
{
table [k].setId(idNo);
table [k].setScore(score);
table [k].setMod(idNo, score);
}
2.
Student *table;
int tSize = 20;
table = new Student [tSize];
for (int i = 0; i < tSize; i++)
table [i] (-999, -999);
My problems are:
at 1, I got error: request for member 'method', which is of non-class type 'int'.
at 2, I got error: no match to call (class) (int, int)
can someone help me understand what I'm doing wrong here? Noted that I haven't covered vector yet, so I'm forced to use an array of objects.