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

The capital of the Ghana Empire was _____.
Which sentence uses a prepositional phrase? Given the economic and political unrest, the family decided to emigrate. Ruling brutally, the harsh dictator caused
what is y=3(x-2)^2-4 in standard form?
4:7=12:21. True or False
what is the purpose of the organization known as APEC
Which character trait fits best the character Suyuan Woo from the story "Two Kinds" by Amy Tan?
which is the force that slows a book sliding ona table
What causes a drop in female hormone levels? A: The onset of the menstrual flow. B: If an egg is released from the ovary. C: if the uterine
Which of the following did President Andrew Jackson oppose? A) the spoils system B) the Indian Removal Act C) the Electoral College D) the presidential veto
Estimate the area of the circle .Use 22 over 7. Please help me...with this question I am stuck.