От: | DTF | ||
Дата: | 04.02.18 19:11 | ||
Оценка: | 1 (1) |
#include <string>
#include <stdexcept>
class TMyException : public std::runtime_error
{
public:
TMyException() : std::runtime_error(message) {}
virtual const char* what() const noexcept {
return message.c_str();
}
private:
std::string message;
};
int main()
{
TMyException ex;
return 0;
}
terminate called after throwing an instance of 'std::bad_alloc'
what(): std::bad_alloc
Аварийный останов (стек памяти сброшен на диск)
terminate called after throwing an instance of 'std::logic_error'
what(): basic_string::_S_construct null not valid
Аварийный останов (стек памяти сброшен на диск)