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
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 "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
std::copy(std::istream_iterator
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started