Ok, im pulling my hair out now...Im new to c++ but this one error is eluding me. Probably due to the fact that I'm still trying to understand pointers. Can anyone point me in the right direction to fix this error:
request for member ‘outputData’ in ‘*(employee**)(& emp)’, which is of non-class type ‘employee*’
Heres the offending code: (the call to emp->outputData is the trigger)
void employee::outputData() {
employee::headers();
int i=0;
while(fin>>emp_id>>fname>>lname>>hours_worked>>hourly_rate>>employee_type_flag>>given_gross_pay) {
if (employee_type_flag == 's') {
employee *emp = new salary_employee();
} else if (employee_type_flag == 'h') {
employee *emp = new hourly_employee();
} // end employee_type check
calc_gross_pay();
calc_net_pay();
cout << setw(20) << emp_id;
cout << setw(20) << fname;
cout << setw(20) << lname;
cout << setw(20) << setprecision(5) << hours_worked;
cout << setw(20) << setprecision(5) << overtime_hours;
cout << setw(12) << setprecision(6) << gross_pay;
cout << setw(12) << setprecision(4) << taxrate;
cout << setw(12) << setprecision(4) << tax_amt;
cout << setw(12) << setprecision(5) << net_pay;
cout << endl;
avg_array[i] = net_pay;
i++;} //end while loop
avg(avg_array);
//
};
int main() {
employee *emp[10];
emp->outputData();
return 0;
}
Much thanks in advance.