Jason Chimera SE 7039990101
Mike Knuble SSE 7039990102
Karl Alzner JSE 7039990202
Tom Poti SE 7039990203
Alex Ovechkin EGM 7039990001
I am trying to read in the information above from a file and sort it by last name. How can I fix this error:
Error:expected a ':'
for the strings I declared in the EmployeeInformation class?
class EmployeeInformation {
public string firstName;
public string lastName;
public string title;
public string phonenumber;
EmployeeInformation(&firstName, &lastName, &title, &phonenumber)
{
this->firstName = firstName;
this->lastName = lastName;
this->initials = title;
this->id = phoneumber;
}
};
#include <vector>
#include <algorithm>
#include <iostream>
#include <fstream>
using namespace std;
int main(int argc, char**argv) {
ifstream file;
file.open("employees.txt");
if (!file.is_open())
cout << "Error opening file";
vector<EmployeeInformation> employees;
while (!file.eof())
{
string firstName, lastName, title, phonenumber;
file >> firstName >> lastName >> title >> phonenumber;
EmployeeInformation person(firstName, lastName, title, phonenumber);
employees.push_back(person);
// end file
}
sort(employees.begin(), employees.end(), [](EmployeeInformation a, EmployeeInformation b) { return a.lastName < b.lastName });
for (EmployeeInformation i : employees)
// print person info in sorted order
return 0;
}