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

Write the equation of the function graphed below: a. f(x) = 2x−−√3 –4 b. f(x) = 2x−−√3 + 4 c. f(x) =x−−√3 + 4 d. f(x) =x−−√3 – 4
A person who is 1.7 meters tall want to know the height of the center of a Ferris wheel from the ground in the amusement park, if he is 40 meters away and looki
Which is greater, -6.4 or -6.5? please explain !!
2. Summarize the Navajo creation ceremony.
The number of eggs Mia can sell varies directly with the number of chickens she owns. The more hens she owns, the more eggs she can sell. If she has 38 eggs eac
Management at Work A hurricane has disrupted operations at one of your company’s facilities and shut down operations completely for several of your key supplier
we’re fugitive slaves treated like other American citizens when brought before the court? explain
work out the m and c for the line 3y+2x=-1
Match each environmental factor with the human response for it
what is the mass of the product of 111.6g and 48g