#ifndef __ERROR_HPP__ #define __ERROR_HPP__ #include std::string itos(int n) { std::string str = ""; while (n > 0) { str = (char)(n % 10 + int('0')) + str; n = n / 10; } return str; } // parent class class Error { protected: std::string msg; public: Error(const std::string& func = "", const std::string& fname = "", const int line = -1) { msg = ""; if (func != "") msg = msg + "Function Name: " + func; if (fname != "") msg = msg + " File Name: " + fname; if (line != -1) msg = msg + " Line Number: " + itos(line); } virtual std::string message() const { return "Error: "+ msg; } }; #endif