Write a c++ program where you can use multiple catch block in a single program using single try block.
Answers
Answered by
3
void test(int x) {
try {
if (x > 0)
throw x;
else
throw 'x';
} catch (int x) {
cout << "Catch a integer and that integer is:" << x;
} catch (char x) {
cout << "Catch a character and that character is:" << x;
}
}
void main() {
clrscr();
cout << "Testing multiple catches\n:";
test(10);
test(0);
getch();
}
Similar questions
History,
6 months ago
English,
6 months ago
Biology,
1 year ago
Math,
1 year ago
World Languages,
1 year ago