#include#include class A { public: A(int n) : m_n(n) { if (0 == n) { throw std::logic_error("0"); } } ~A() { std::cout << m_n; } public: const int m_n; }; int main() { try { A a(1); A b(0); A c(2); } catch (const std::exception &) { std::cout << 3; } std::cout << std::endl; return 0; }
No comments:
Post a Comment