Question: I need help making a simple hash function for a c++ programming assignment. In the assignment you will take a list of employee data and

I need help making a simple hash function for a c++ programming assignment. In the assignment you will take a list of employee data and use it to generate an employee ID by implementing a hash function. I can't rename any existing functions or add any additional function or member variables. The program will read in a text file containing a list of employees. The program will iterate those employees and generate an ID for each. The program will output the ID along with the rest of the employee data to the output file. The ID should be limited to no more than 6 digits and will be numeric. The only changes will be to the employee.cpp file.

employee.h:

#ifndef __EMPLOYEE_H__ #define __EMPLOYEE_H__

#include #include

struct Employee { std::string FirstName; std::string LastName; std::string Phone; std::string Email; std::string Address;

std::size_t hash() const; };

inline std::istream& operator>>(std::istream& is, Employee& e) { is >> e.LastName >> e.FirstName >> e.Phone >> e.Email; std::getline(is, e.Address); return is; }

inline std::ostream& operator<<(std::ostream& os, const Employee& e) { os << e.LastName << "\t" << e.FirstName << "\t" << e.Phone << "\t" << e.Email << "\t" << e.Address; }

#endif // __EMPLOYEE_H__

main.cpp:

#include #include #include #include #include #include #include

#include "employee.h"

int main(int argc, char** argv) { if (argc != 3) { std::cout << "Usage: assignment08 [input file] [output file]" << std::endl; return 0; }

std::ifstream fin(argv[1]); std::ofstream fout(argv[2]);

std::deque employees;

std::copy(std::istream_iterator(fin), std::istream_iterator(), std::back_inserter(employees)); std::for_each(employees.begin(), employees.end(), [&](const Employee& e) { fout << e.hash() << "\t" << e << std::endl; });

return 0; }

employee.cpp:

#include

#include "employee.h"

std::size_t Employee::hash() const { //to do }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!