ok. My working code is below. what I now need to do is read from a file, which needs to be done with the overloaded>>. each field I read needs to be assigned to a variable listed in my class. I will also include my data file. Some general hints would be useful, as I have never overloaded a variable before in this way. Thanks for any input!
Datafile:
Smith|Jane|2105 E. J Avenue|Nowhere|Michigan|33333|H|1030|80|2
Code:
#include<iostream>
#include<fstream>
#include<string>
#include<cstdlib>
using namespace std;
class employee
{
public:
string lname;
string fname;
string address;
string city;
string state;
string zip;
char hos;
int payrate;
int hours;
int dependents;
int gpay;
int fed;
int state1;
int social;
int net;
int compute(int payrate, int hours, int dependents, int gpay, int fed, int state1, int social, int net, char hos);
};
employee::employee();
int main()
{
char in[20];
char out[20];
char str[1024], last;
cout<<"Enter the name of the file you want to write to."<<endl;
cin.get(out, 20);
cin.ignore(80, '\n');
cout<<"Enter the name of the file you want to read from."<<endl;
cin.get(in, 20);
cin.ignore(80, '\n');
ifstream infile;
infile.open(in);
ofstream outfile;
outfile.open(out);
/*while(!infile.eof())
{
infile.get(str, 1023, '|');
cout<<str<<endl;
infile.get(last);
}*/
employee::lname=infile.get>>
cout<<employee::lname;
employee compute(int payrate, int hours, int dependents, int gpay, int fed, int state1, int social, int net, char hos);
infile.close();
outfile.close();
return 0;
}