10.5 Programming Project #5: File I/O solution

$29.99 $20.99



Background Recall that we are iterating on the development of a payroll program. At this point, you should have a working Employee class. In this project you will add the ability for objects of your Employee class to write themselves out to a file, and be read in from a file. The ability for an object to save itself in a file is called persistence. You will also throw an exception if there are any file I/O errors. Get your program working without exception handling first. Then add the exception handling. Objectives • Continue to refine your object oriented design skills. • Create the proper structure and code for a C++ program containing a class of your design. • Create a class that has persistence. • Throw and handle an exception. • Create a main() function to test the additions to your class. The Employee Class For this project you need to add the following member functions to your Employee class. Employee read(ifstream&) void write(ofstream&)
The function Employee::read is a static member function. It returns an Employee object based on the data it reads from a file. It must be called as Employee::read(…) since it’s job is to create an object. If there is a read error, it throws a std::runtime_error(defined in