C++98 | default (1) |
exception() throw(); |
copy (2) |
exception (const exception& e) throw(); |
// exception constructor #include <iostream> // std::cout #include <exception> // std::exception struct ooops : std::exception { const char* what() const noexcept {return "Ooops!\n";} }; int main () { ooops e; std::exception* p = &e; try { throw e; // throwing copy-constructs: ooops(e) } catch (std::exception& ex) { std::cout << ex.what(); } try { throw *p; // throwing copy-constructs: std::exception(*p) } catch (std::exception& ex) { std::cout << ex.what(); } return 0; } |
exception::what | 获取字符串识别异常(公共成员函数) |
exception::operator= | 复制异常(公众成员函数) |