Error while using member fucntion of class
Aug 22, 2014 at 12:41pm UTC
So I'm trying to make an array of objects with the following codes
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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
class Student
{
public :
Student ();
Student (int , int );
~Student ();
void setMod (int , int );
void setId (int );
void setScore (int );
int getId () const ;
int getScore () 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;
}
....
//initialization
Student *table;
int tSize = 20;
table = new Student [tSize];
for (int i = 0; i < tSize; i++)
table [i] (-999, -999);
...
//code fragment with error
if (table [k].getId () == -999)
{
table [k].setId(idNo);
table [k].setScore(score);
table [k].setMod(idNo, score);
}
each time i tried to use
I got the following error:
"request for member 'function' in '*(((int)(((unsign_int)i)*4u))+array)' which is of non-class type 'int'"
Can anyone tell me what am I doing wrong here?
Aug 22, 2014 at 1:35pm UTC
http://www.eelis.net/iso-c++/testcase.xhtml
A testcase is said to reproduce the problem if, when we independently try to compile and run the testcase locally, we get the same compiler error (or our compiler's version of it)
A testcase consisting of randomly copy&paste'd bits of code that you thought were relevant can obviously not reproduce the problem.
>
table [i] (-999, -999);
error: no match for call to ‘(Student) (int, int)’
Topic archived. No new replies allowed.