Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

exception handling class c++

#include <bits/stdc++.h>
using namespace std;
int main()
{
    int x=-1,y=1;
    try
    {
        if(x<0)
        {
            throw("xisnegative");
        }
    }
    catch(const char *exp)
    {
        cout<<exp<<endl;
    }
    try
    {
        if(y>0)
        {
            throw("yispositive");
        }
    }
    catch(const char *exp)
    {
        cout<<exp<<endl;;
    }
    return 0;
}
 
PREVIOUS NEXT
Tagged: #exception #handling #class
ADD COMMENT
Topic
Name
4+3 =