Ask Question
17 March, 12:10

How can an exception be explicitly raised in C++? How are exceptions bound to handlers in C++?

+4
Answers (1)
  1. 17 March, 15:25
    0
    Exceptions are raised using throw statement in c++.

    Explanation:

    Try block is used to keep the statements which we felt that they will raise an exception. Catch block is used to catch the exception which is thrown by the try block.

    #include

    void main () {

    int x, y, z;

    try{

    cout<"enter 2 numbers";

    cin>>x>>y;

    if (y==0)

    throw y;

    z=x/y;

    }

    catch (int x) {

    cout<<"exception caught";

    }

    }
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “How can an exception be explicitly raised in C++? How are exceptions bound to handlers in C++? ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers