+ 3

Rearrange the code to define a function "foo", which throws an exception with a value of "-100" if its parameter is greater than

Rearrange the code to define a function "foo", which throws an exception with a value of "-100" if its parameter is greater than 999. Then "foo" catches its exceptions and prints "error!" to the screen. void foo(int arg) { try { if (arg > 999) throw -100; } catch (int x) { cout << "error!" << endl; } }

18th May 2017, 8:23 PM
Jorge Luis
8 ответов
+ 3
void foo(int arg) { try { if (arg > 999) throw -100; } catch (int x) { cout << "error!" << endl; } }
19th Mar 2018, 2:18 PM
Mahnoor Shahzad
Mahnoor Shahzad - avatar
+ 2
I think the question is do my homework
18th May 2017, 9:25 PM
jay
jay - avatar
+ 1
What is your question?
18th May 2017, 8:25 PM
Maart
Maart - avatar
+ 1
catch (int) { try { }
19th May 2017, 1:52 AM
Jorge Luis
0
void foo(int arg) { try { if (arg > 999) throw -100; } catch (int x) { cout << "error!" << endl; } }
22nd Aug 2019, 5:57 AM
Alexander Salazar
0
thanks all for your supports
4th Jun 2020, 6:26 AM
Waled Moumari
Waled Moumari - avatar
0
Rearrange the code to define a function "foo", which throws an exception with a value of "-100" if its parameter is greater than 999. Then "foo" catches its exceptions and prints "error!" to the screen. Answer: void foo(int arg) { try { if (arg > 999) throw -100; } catch (int x) { cout << "error!" << endl; } } Q&A
23rd Sep 2020, 12:20 AM
OjeifoIduma
- 1
thanks all
4th Jun 2020, 6:51 AM
Waled Moumari
Waled Moumari - avatar