Dec 5, 2012 at 3:27am UTC
every time i try to run my program i keep getting an identification error for empInfo. i tried putting int empInfo; but it wont work can someone please help me out. thank you in advance for your help
#include <stdlib.h>
#include <iostream>
using namespace std;
class employee
{
private:
int id, maxHours;
float payRate;
public:
void setInfo (int pin, float pay, int hours)
{
empInfo[pin].id = pin;
empInfo[pin].payRate = pay;
empInfo[pin].maxHours = hours;
}
void viewInfo (int record)
{
cout << empInfo[record].id;
cout << endl << empInfo[record].payRate;
cout << endl << empInfo[record].maxHours;
}
};
int main ( )
{
int pin, hours, record;
float pay;
employee empInfo[1000];
cout << "Enter employee 3 digit ID: ";
cin >> pin;
cout << "Enter employee pay rate: ";
cin >> pay;
cout << "Enter employee max hours: ";
cin >> hours;
empInfo[pin].setData(pin, pay, hours);
cout << "Enter the employee ID# of the record you wish to view: " << endl;
cin >> record;
empInfo.viewDate(record);
system("PAUSE");
return 0;
}
Dec 5, 2012 at 4:11am UTC
empInfo is declared in main but random methods inside the employee class are trying to modify it.
Dec 5, 2012 at 9:59am UTC
I go to the lounge to relax!
Dec 5, 2012 at 6:32pm UTC
You should put this in the beginner's fourm