#ifndef _ErrorWordsShepherd #define _ErrorWordsShepherd #include #include short const MAX_FRAMES = 20; class ErrorWords { ErrorWords() {} friend class ErrorWordsShepherd; int errorNumber_; int line_; std::string fname_; }; class ErrorWordsShepherd { public: ErrorWordsShepherd() : index_(0) {} int SetErrorWords(int error_num, char* fname, int line) { if (index_ >= MAX_FRAMES) { return 0; } errorWords[index_].errorNumber_ = error_num; errorWords[index_].fname_ = fname; errorWords[index_].line_ = line; ++index_; return 1; } void ListErrorWords() { for (int i = 0; i < index_; ++i) { std::cout << "errno is " << errorWords[i].errorNumber_ << ".\n"; std::cout << "File name: " << errorWords[i].fname_ << " "; std::cout << "Line number: " << errorWords[i].line_ << ".\n\n"; } } void Reset() { index_ = 0; } private: ErrorWords errorWords[MAX_FRAMES]; int index_; }; #endif