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

Can someone please help me? I don't understand question d.
Jelly fakes sell for $1.23 for 1/4 pound bag. How much for 4 pounds of jelly fakes?
Express the ratio 7/30: 1/4 in the form of r:s in lowest terms, where r and s are integers
Which career professionals typically has the highest level of education? A) Systems Analysts B) Support Specialists C) Computer Systems Engineers/Architects D)
Find 5 7/9 divided by 3. Simply & write as mixed number.
What strategies can you use to develop a rebuttal to a counterclaim in an argument essay? Select all that apply A. Explain why no one should believe the counte
Express 1.3 as a percent.
Say the slope value of the next line -x + y = 10 a. m = -1 b. m = 0 c. m = 10 d. m = 1
Say the slope value of the next line -x + y = 10 a. m = -1 b. m = 0 c. m = 10 d. m = 1
A teacher has 15 weeks in which to teach six chapters. Write and then solve an equation, showing all work, that represents the number of lessons the teacher mus