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 words to match the expression. 24- ( 6+3)
which city was located nearest the nile river delta
If you are writing a persuasive essay in favor of banning vending machines in schools, which is a counterargument you might anticipate?
Which two numbers have a difference of 5 and a product of 3.36???
which city was located nearest the nile river delta
which city was located nearest the nile river delta
If you are writing a persuasive essay in favor of banning vending machines in schools, which is a counterargument you might anticipate?
If you are writing a persuasive essay in favor of banning vending machines in schools, which is a counterargument you might anticipate?
Which two numbers have a difference of 5 and a product of 3.36???
If you are writing a persuasive essay in favor of banning vending machines in schools, which is a counterargument you might anticipate?