[Home]
[Edit this page]
[Recent Changes]
[Special Pages]
[Help]
CppExceptionHandling
[Edit this page] [Page history] [What links here] [Discuss this topic] [Printer Friendly]
CppExceptionHandling
(C++) Exception handling
The handling of an exception using the keywords try and catch. Due to exception handling, code get exception safe.class Test { public: Test() {} void doThrow() { throw std::exception(); } }; int main() { Test test; try { test.doThrow(); } catch(std::exception& myException) { std::cout << "Catched and recognized the exception" << std::endl; } catch(...) { std::cout << "Catched unknown exception" << std::endl; } std::cout << "Done.." << std::endl; }
- include <iostream>
- include <exception>
[Edit this page] [Page history] [What links here] [Discuss this topic] [Printer Friendly]
