OOPS !
correction.... its the std::runtime_error that i should inheit from, not std::exception.
but i think the code you gave me is the same, except i need to use a iffernent library < stdexcept > instad of < exception >
edit:
oops, nope. my following class generate the errors shown...
Code:
#ifndef CXS12U_EXCEPTIONS_HPP
#define CXS12U_EXCEPTIONS_HPP
#include<exception>
#include <stdexcept>
namespace jminus {
class interpreter_exception : public std::runtime_error {
private:
std::string m_what;
public:
explicit interpreter_exception(const std::string& what) : m_what(what) {
//m_what = what;
}
~interpreter_exception() throw() {}
const char* what() const throw() {
return m_what.c_str();
}
};
}
#endif
Code:
bash-2.05b$ g++ src/main.cpp -o bin/jminus
In file included from src/main.cpp:12:
src/jminus/exceptions.hpp: In constructor `jminus::interpreter_exception::interpreter_exception(const std::string&)':
src/jminus/exceptions.hpp:17: error: no matching function for call to `std::runtime_error::runtime_error()'
/usr/lib/gcc/x86_64-pc-linux-gnu/3.4.3/include/g++-v3/stdexcept:109: note: candidates are: std::runtime_error::runtime_error(const std::runtime_error&)
/usr/lib/gcc/x86_64-pc-linux-gnu/3.4.3/include/g++-v3/stdexcept:115: note: std::runtime_error::runtime_error(const std::string&)
any idea's ??
If i could find decent documentation on etd::exception class, i could do all this myself.
my c++ book is quite old, and only goes as far as throwing intergers floats, bools and char's for exceptions !