I've just created exception hierarchy and wanted to pass char*
to constructor of one of my derived classes with a message telling what's wrong, but apparently std::exception
doesn't have constructor which would allow me to do so. Yet there is a class member called what()
which would suggest that some information can be passed.
How can I (can I?) pass text to derived class of a std::exception
in order to pass info with my exception class, so I can say somewhere in the code:
throw My_Exception("Something bad happened.");
See Question&Answers more detail:os