I come with a perhaps odd question. I was doing an exercise and I ran into a problem. The point was to make an Employee class, and then a function that has an array of Employee** and its size as an argument, and to make it show every employee with more than 5 years of experience.
Here is the relevant pieces of the Employee class:
//in Employee.h:
int Getexperience() { return experience; }
virtual void show();
//in Employee.cpp:
void Employee::show()
{
cout << "Name: " << this->surname << ", Age: " << this->age << ", Experience: " << this->experience << ", Salary: " << this->salary << endl;
}
And here's the function, written in main.cpp:
void whoWorkMoreThan5Years(Employee** tab[], int size){
for(int i =0; i<size; i++){
if(tab[i]->Getexperience() > 5){
tab[i]->show();
}
}
}
This gets me the error:
error: request for member 'Getexperience' in '* *(tab + ((sizetype)(((unsigned int)i) * 4u)))', which is of pointer type 'Employee*' (maybe you meant to use '->' ?)|
And I honestly have no clue what it's even supposed to mean since
- I am using a '->' for the object's method.
- I don't know what the '* *(tab + ((sizetype)(((unsigned int)i) * 4u)))' part even refers to.
I guess my question is basically: what am I doing wrong here? Is there any special way to use an object's methods in this situation that I just don't know?