0
How do we achieve exception handling in c++ with an example.Can anyone tell plzz ..
7 Respuestas
+ 1
Ok thank you for the help
+ 1
#include <iostream>
using namespace std;
int main() {
int no = -1;
try{
if (no < 0)
throw no;
cout << "Success no = " << no;
}
catch(int n){
cout << "Negative no = " << n << endl;
}
return 0;
}
/*
suppose you want your code to handle only positive number i.e no > 0 , so using exception handled one of the way is by doing this */
0
Why does try didn't come in this?
0
did you swipe right to see the other content?
0
Yes i did but there is throwing exection and catching expection only
0
there is a ( try ) code in the last page.
the link above has three pages.