C + + exception handling

Source: Internet
Author: User

Detailed introduction can see CSDN official introduction, link address http://msdn.microsoft.com/zh-cn/library/hh279678.aspx

Here are the examples in your app:

1     2#include <stdexcept>//Exception Handling Library3 4 //the inner parameter matrix MK is reversed and printed to show its inverse matrix5     Try    //exception Handling in cases where k is a singular matrix irreversible6     {7         if(Invert (MK,MINVK,CV::D ecomp_lu))//matrix inversion, if the matrix is singular matrix, the condition is not established8         {9Std::cout << minvk << Std::endl;//Print display matrix dataTen         } One         Else    //k is singular matrix A         { -             ThrowStd::invalid_argument ("error:intrinsic parameter K is singular."); -                 //Throw exception "K for singular matrix" the         } -     } -     Catch(std::invalid_argument& e)//Get Exception condition -     { +Std::cerr << e.what () << Std::endl;//Print Exception Alert -         return-1; +}

C + + exception handling

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.