There are many ways to create a new exception that is derived from some other exception. One way is to use something like this
struct MyException : public exception
{
const char * what () const throw ()
{
return "C++ Exception";
}
};
and another way is to call the constructor of the base class.
class My:public runtime_error
{
public:
My(string s):runtime_error(s){}
};
The second method obviously gives me the advantage to insert (at creation) the string that is output by the what() method. My question is which method should I prefer and whether I need to use the first method at all.