Payroll Class App

HI, so i need to make a program that reads from file and displays info. but a class has to be used and header and and another cpp file for implementation, i have some of a structure but as he is keen on us using Visual Studios i get the stdafx.h error tho i added it into the .h file. The 3 files r down below. Error im getting:Severity Code Description Project File Line Suppression State
Error C1010 unexpected end of file while looking for precompiled header. Did you forget to add '#include "stdafx.h"' to your source? Project 4 main c:\users\ariz\source\repos\project 4 main\project 4 main\emppayroll.cpp 62




[code]
.h file
#include "stdafx.h"
#include <iostream>
#include <fstream>
#include<sstream>
using namespace std;

class EmpPayroll
{
private:
string name;
int id;
double rate;
double hrWrked;
double wage;

public:
void readfile();

EmpPayroll();
EmpPayroll(string n, int i, double r, double hr);


double calculate_wages();
void display();


void set_name(string n);
string get_name();
void set_id(int i);
int get_id();
void set_rate(double r);
double get_rate();
void set_hrWrked(double hr);
double get_hrWrked();



};
main file:
// Project 4.cpp : Defines the entry point for the console application.
//

#include "EmpPayroll.h"

#include "stdafx.h"

int main()
{



return 0;
}

other cpp file:
#include"EmpPayroll.h"
#include "stdafx.h"

EmpPayroll::EmpPayroll()
{
name = "";
id = 0;
rate = 0.0;
hrWrked = 0.0;
}
EmpPayroll::EmpPayroll(string n, int i, double r, double hr)
{
name = n;
id = i;
rate = r;
hrWrked = hr;
}



void EmpPayroll :: readfile()
{

int counter = 0;
EmpPayroll emp;
ifstream file;
file.open("Project 3.dat");

if (file.is_open())
{

while (!file.eof())
{
string s;
switch (counter)
{
case 0:
emp.set_name(s);
break;
case 1:
emp.set_id(stoi(s));
break;
case 2:
emp.set_rate(stod(s));
break;
case 3:
emp.set_hrWrked(stod(s));
break;
}


}
}

else
{
cout << "Warninng! file not found" << endl;
}

}


Last edited on
Topic archived. No new replies allowed.