Hello all, I am at the beginning of a new program working with structs and I am getting an error I cannot figure out. My code so far is
//PJ901 PAtrick Nealey
//Acme Payroll Program
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstring> // for _strcmp
using namespace std;
const int MaxNameLen = 21; //sets maximm name lenght to 20
const int MaxEmployees = 500; //sets maximum number of employee records to 500
enum PayType{Salary, Hourly};
struct Employee{
int id; //employee ID number
char name[MaxNameLen]; //employee name
double pay_rate; //employee pay rate
short int dependants; //employee's number of dependants
PayType pt; //determines wether employee is paid hourly or is on salary
};
int LoadMaster (Employee employee[]);
int main()
{
Employee employee[MaxEmployees]; //Array of employee recoeds
int numemployees; //number of employees in array
numemployees = LoadMaster( employee );
//cout >>"number of employees =">>numemployees;
}
int LoadMaster (Employee employee[MaxEmployees])
{
int idx = 0; //array index
char delimiter; //delimiter symbol used in the input file.
ifstream infile( "PJ901master.txt" );
if( !infile )
{
cerr << "Could not open the input file." << endl;
exit(1);
}
while( idx < MaxEmployees && infile >> delimiter &&
infile.getline( employee[ idx ].name, sizeof(employee[ idx ].name), ' ' ) )
{
infile >> employee[ idx].id >> employee[ idx].name
>> employee[idx].pay_rate >> employee[idx].dependants >> employee[idx].pt;
idx++;
}
//TEST THE INPUT STREAM STATUS
if( idx == MaxEmployees && infile >>ws && infile.good() )
{
cerr << "Too many data.\n";
exit( 3 );
}
if( !infile.eof() && infile.fail() )
{
cerr << "Bad data.\n";
exit( 4 );
}
return idx;
}
I am getting an error on line 52 which states "error C2679: binary '>>' : no operator found which takes a right-hand operand of type 'PayType' (or there is no acceptable conversion)"
Any ideas?