Код: Выделить всё
#include <exception>
#include <iostream>
class myException: public std::exception
{
public:
myException (const std::string& __what__): _what_ (__what__)
{
};
virtual ~myException () throw ()
{
};
virtual const char* what ()
{
return _what_.c_str();
};
private:
std::string _what_;
};
class A
{
public:
A ()
{
};
void a ()
{
throw myException ("A::a()");
};
};
int
main ()
{
try
{
A a;
a.a ();
}
catch (std::exception& e)
// catch (myException& e)
{
std::cout << e.what() << std::endl;
};
return 0;
};Этот код вместо "A::a()" выводит "11myException".
Я как-то не так понимаю исключения?