Una volta che derivo la classe da std::exception o da boost::exception, come se faccio se voglio decidere io che messaggio stampare? Puoi fare un esempio?
edit:
Mi spiego meglio, a me stampa sempre messaggi che non sono significativi, mi dice ad esempio :
codice:
Terminate called after throwing an instance of' excp1*'
Aborted
Ma io vorrei che mi stampasse un messaggio più significativo, ad esempio ho provato così:
codice:
#include <iostream>
#include <exception>
using namespace std;
class excp1:exception
{
public:
virtual const char* what() const throw()
{
return "Bad ass exception";
}
};
int main(int argc, char **argv)
{
try
{
if(1!=0)
throw new excp1();
}
catch(excp1& e)
{
cerr<<e.what();
}
return 0;
}
Ma non mi stampa mai il messaggio "Bad ass exception".