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.

I dont know how your class is defined, but I am just gonna be doing a wild guess here:

employee *emp[10];
   emp->outputData();

Looks like an array of pointers to objects of class "employee",
First this means that your objects will not be automatically created (try putting a cout statement in your default constructor to check it out),
So to create an object and stores its reference in the "emp"array you will need to manually specify

emp[0]=new employee(...);

or some other method.

Also consider the second line, since you are creating an array of pointers, u need to tell the pointer at which index to use while using the "emp" array.
ex:

emp[0]->outputData();

However just guessing here, I couldn't try your code directly here.

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.

Try:

emp[0]->outputData();

Or any integer from 0 - 9 as the index. I have no idea whether that will do what you want, but it'll probably compile at least. You are treating an array of pointers to employee as identical to a pointer to employee. You cannot do that.

Looks like someone else beat me to it with largely the same post, so I'll stop here.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.