otakugirl539 otakugirl539
  • 14-09-2019
  • Computers and Technology
contestada

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

Respuesta :

flightbath flightbath
  • 19-09-2019

Answer:

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<iostream.h>

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";

}

}

Answer Link

Otras preguntas

eastern countries typically tend to value ___, ____, and ____. they also tend to think ____.
HELP ME PLZZZ SMNSNSNS D D D D D D D D D D
Lily can travel 60 miles in 1.5 hours. If her speed is reduced by 5 mph, how far can she travel in 3 hours?
PLS ANSWER!!! Lori graphed f(x) = −34x − 1 and g(x) = −4f(x) on the same coordinate plane. Which statements below incorrectly describe how the graphs of f(x)and
60 POINTS!!!! Please, Don't Use The Question For Points. Help Me Before Today Ends!!!! Question: Jason wants to plant 72 carrot seeds and 18 onion bulbs. He wou
Which coefficient is needed in front of NaNO3 to balance the equation Na2S Zn(NO3)2 → ZnS _NaNO3? 1 2 5 7.
Solve the math problem
Why is religon important to world culture? I just want a good thesis for this
why is it impossible to define the boundary between humid climates and dry climates by a single precipitation amount?
Which definition best matches the way the word afford is used in line 4?