Available Standard Exceptions types and using them in c++





This video tutorial explains what are the standard Exception types available in c++ and also how to use the runtime_error in your program.
You are gonna learn about the exception class, standard exception classes and their dreived types, how to throw an object as Exception in detail with example.

source code for this tutorial

#include <iostream>
#include <stdexcept>

using namespace std;

int main()
{

    int a = 10, b= 0, c;

    try{
    if( b == 0 )
        throw runtime_error("divide by zero error");
    c = a/b;

    cout << c<<endl;
    }catch(runtime_error &error){

    cout << "exception accured"<<endl;
    cout << error.what();
    }

    return 0;
}

 
Back To Top