I am confused with passing my values from my function to my other function by refrence ( not using a pointer ) I am trying to have my houremployee function to be able to change the values of hours and wage. The project requires this done with a refrence and every time I try I get different errors. Can someone explain what the best way to do this would be?
1 2 3 4 5 6 7 8 9 10 11 12 13
void employeePayRoll::printHourEmployee()
{
double hours, wage;
cout << "Please enter the hours worked by the employee" << endl;
cin >> hours;
cout << "Please enter the hourly wage of the employee" << endl;
cin >> wage;
hourEmployee(hours,wage);
double employeePayRoll::hourEmployee(double hourWorked,double hourWage)
}
You pass by reference by adding &. That'll mean your function will have access to your original variable rather than make a copy like passing by value does.
It would also be nice if you posted your errors since we cant read minds :)