Search
 
SCRIPT & CODE EXAMPLE
 

CPP

error handling in C++

try  {
       throw 10; //Error Detected and "Thrown" to catch block
    }
catch (char *excp)  { //if error is thrown matches this block, exec
        cout << "Caught " << excp;
    }
catch (...)  { //default case
        cout << "Default Exception
";
    }
Comment

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;
}
Comment

PREVIOUS NEXT
Code Example
Cpp :: c++ data types 
Cpp :: opencv c++ feature detection 
Cpp :: c++ insert variable into string 
Cpp :: cpp execute command 
Cpp :: how to sort array in c++ stockoverflow 
Cpp :: toString method in c++ using sstream 
Cpp :: int max in c++ 
Cpp :: c++ loop trhought object 
Cpp :: long long int range c++ 
Cpp :: text color c++ 
Cpp :: max pooling in c++ 
Cpp :: array copx c++ 
Cpp :: how to reset linerenderer unity 
Cpp :: set size of a vector c++ 
Cpp :: square gcode 
Cpp :: volumeof a sphere 
Cpp :: lists occurrences of characters in the string c++ 
Cpp :: Shuffle String leetcode solution in c++ 
Cpp :: how to print an array in cpp in single line 
Cpp :: c++ lambda as variable 
Cpp :: oop in c++ have 5 
Cpp :: options select from array 
Cpp :: memcpy in cpp 
Cpp :: binary to decimal 
Cpp :: activity selection problem 
Cpp :: c++ add everything in a vector 
Cpp :: InstallUtil.exe ConsoleApp 
Cpp :: C# adding numbers 
Cpp :: how-to-read-until-eof-from-cin-in-c++ 
Cpp :: c++ throe 
ADD CONTENT
Topic
Content
Source link
Name
3+5 =