#ifndef H_Person
#define H_Person
#include <string>
usingnamespace std;
class Person
{
public:
//Function to output the first name and last name
//in the form firstName lastName
void print() const;
//Function to set firstNAme and lastName according to the parameters
//Postcondition: firstName = first; lastName = last;
void setName (string first, string last);
//Function to return firstName
//Postcondition: The value of firstName is returned.
string getFirstName() const;
//Function to return lastName
//Postcondition: The value of lastName is returned.
string getLastName() const;
//Constructor
//Sets firstName and lastName according to parameters
//The default value of the parameters are null string.
//Postcondition: firstName = first; lastName = last;
Person(string first = " ", string last = " ");
private:
//Variable to store the first name
string firstName;
//Variable to store last name
string lastName;
};
#endif
#include <iostream>
#include <fstream>
#include <string>
#include "Employee.h"
usingnamespace std;
constint MAX_NO_OF_EMPLOYEES = 10;
void getEmployeeData(ifstream& infile, Employee employeeList[], int numberOFEmployees);
void printEmployeeReport(ofstream& outfile, Employee employeeList[], int numberOFEmployees);
int main()
{
Employee employeeList[MAX_NO_OF_EMPLOYEES];
int noOFEmployees;
ifstream infile;
ofstream outfile;
infile.open("Data.txt");
if(!infile)
{
cout << "The input file does not exist. " << "Program terminates. " << endl;
return 1;
}
outfile.open("DataOut.txt");
//get number of employees
infile >> noOFEmployees;
getEmployeeData(infile, employeeList, noOFEmployees);
printEmployeeReport(outfile, employeeList, noOFEmployees);
return 0;
}
void getEmployeeData(ifstream& infile, Employee employeeList[], int numberOFEmployees)
{
//local variables
//loop control variable
int count;
//Variable to store the first name
string fName;
//Variable to hold last name
string lName;
for(count = 0; count < numberOFEmployees; count++)
infile >> fName >> lName ;
employeeList[count].setInfo(fName, lName);
}
void printEmployeeReport(ofstream& outfile, Employee employeeList[], int numberOFEmployees)
{
int count;
for(count = 0; count < numberOFEmployees; count++)
employeeList[count].print(outfile);
}
Data.txt file
4
Johnathan Witvoet
Lorita Witvoet
Charles Dees
Kathalene Dees
did break point at line 23 in Employee.cpp and get CXX0030: Error: expression cannot be evaluated. looked this error up and it said: You may want to rewrite your expression using parentheses to control the order of evaluation. I stil do not under stand why? any help would be appreciated.