First of all, I did indeed do a quick search on google, and none of it explained what I am shooting for.
Edit: For instance, I looked here.
The class std::runtime_error
is an exception class that signals an error that occurs at runtime. Unless I'm mistaken, it has no default constructor (I got an error when trying to derive from it without explicitly calling a parent constructor) but it does have string(-ish) constructors that allow you to specify a message.
My question is how would you access that message in a member function such as what()
(virtual function in std::exception
)? There is no getMessage()
or similar function defined in the parent class, and calling what()
is rather useless if that happens to be the function I am overriding.
I am using Visual Studio Community 2015, so a compiler-specific method is okay, but I would prefer a portable solution.