Ask Question
10 December, 04:53

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

+3
Answers (1)
  1. 10 December, 07:15
    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?
Find an answer to your question ✅ “How can an exception be explicitly raised in C++? How are exceptions bound to handlers in C++? ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers