How to initialize payRate * hoursWorked from derive class

Dear all, the program cannot display the calculations of payRate * hoursWorked and I suspect that I did not managed to intialize the formula. I have been figuring this for days. Can anyone help? Thanks.

// the Employee class is derived from StaffMember
class Employee : public StaffMember
{
//data declaration section
protected:
double payRate; // add two additional data member
int hoursWorked;
// methods declaration section
public: // two additional member methods
Employee(string n = " ", string ph = " ", double PR = 0.0, int HW= 0) : StaffMember(n, ph), payRate(PR), hoursWorked (HW) {}
double getPay();
void display();
};

// methods implementation section for Employee

double Employee::getPay()
{
return payRate * hoursWorked;
}

This code looks good. The problem should be elsewhere. It really can't be hard to check if initialization is the problem. Print what values you pass to the constructor, and then print the members of the constructed object.
Topic archived. No new replies allowed.