using fstream to read txt, passing data to object

I am trying to read a multi line txt file that has a different type of data on each line, starting over every 4, as in name on one line, pay rate on the next, and so on. I have made an array of objects that each have spots for these five different types of data, but I can't seem to pass the information into them. I do not understand how to make a certain line in the txt file become a variable that can be passed to the object.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#include <iostream>
#include <fstream>
#include <iomanip>
#include <string>
#include <cstdlib>
#include "NBEmployee.h"
using namespace std;


int main (int argc, const char * argv[])
{
    
    NBEmployeeMembers worker[4];
    fstream inFile("employee_data_in.txt", fstream::in);
    //fstream outFile("payroll_check.txt", fStream::out);
    if (!inFile)//error message
    {
        cerr << "File could not be opened" << endl;
        exit(1);
    }
    string empLastName;
    char payrollType;
    int hoursWorked,
        payrate,
        unionCode;
    
    
  char * buffer;
  inFile.seekg (0, ios::end);
  int length = inFile.tellg();
  inFile.seekg (0, ios::beg);

  // allocate memory:
  buffer = new char [length];

  // read data as a block:
  inFile.read (buffer,length);

  

  cout.write (buffer,length);

 
   
    
    
    int j = 0;
    
    //this is where I need most help, i don't know how to pick out individual info
    while (inFile >> empLastName >> payrollType >>
           hoursWorked >> payrate >> unionCode )
    {
        worker[j].EmployeeSet(empLastName, payrollType, hoursWorked, payrate, unionCode);
        j++;     
    }
    
    for (int i = 0; i < 4; i++)
    {
        worker[i].printEmp();
    }
    
    inFile.close();
    return 0;
}

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#ifndef payrollDriver_NBEmployee_h
#define payrollDriver_NBEmployee_h
#include <string>
using namespace std;
class NBEmployeeMembers
{
public:
    NBEmployeeMembers();
    void EmployeeSet(string, char , int , int, int);
    void storeFile(int[]);
    void printEmp();
    
private:
    string lastName;
    char payrollType;
    int hoursWorked;
    int payRate;
    int unionCode;
};

#endif 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <iostream>
#include <string>
#include "NBEmployee.h"
using namespace std;

NBEmployeeMembers::NBEmployeeMembers()
{
    
}

void NBEmployeeMembers::EmployeeSet(string lName, char payroll, int hours, int rate, int unionC)
{
    lastName = lName;
    payrollType = payroll;
    hoursWorked = hours;
    payRate = rate;
    unionCode = unionC;
}

void NBEmployeeMembers::printEmp()
{
    cout << lastName << "\n" << payrollType << "\n" <<
    hoursWorked << "\n" << payRate << "\n" << unionCode;
}


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
Smith
H
40.0
25.0
1
Carter
h
25.0
15.0
3
Lopez
h
50.0
35.0
2
Abdullah
H
55.0
10.0
3
Topic archived. No new replies allowed.