As a general rule of thumb here, you shouldn't be using a set
method to simply return data -- stylistically speaking, this should be getId()
; your setters should actually set data. But then again, it looks like you already have a setter in your parent, so add a getter and remove everything from your child.
Your class could be cleaned up a bit just by following this style.
class Employees{
protected:
int employeeId;
//string name;
public:
void setEmployeeId(int a)
{ employeeId = a; }
int getEmployeeId()
{ return employeeId; }
};
class cashier: public Employees{
public:
// no need for anything here -- the methods you need are inherited
};
int main(){
cashier c;
c.setEmployeeId(29);
cout << "Employee ID: " << c.getEmployeeId() << endl;
}