file.cpp 337 B

1234567891011121314151617181920212223
  1. #include "file.h"
  2. #include <fstream>
  3. #include <stdexcept>
  4. #define ERROR_FILE_OPEN "Cannot open file."
  5. using std::ifstream;
  6. using std::runtime_error;
  7. file_input::file_input(string filename)
  8. {
  9. input = new ifstream(filename);
  10. if (input->fail())
  11. throw runtime_error(ERROR_FILE_OPEN);
  12. }
  13. file_input::~file_input()
  14. {
  15. delete input;
  16. }