+ 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; } }
8 Antworten
+ 3
void foo(int arg) {
try {
if (arg > 999) throw -100; }
catch (int x) {
cout << "error!" << endl; }
}
+ 2
I think the question is do my homework
+ 1
What is your question?
+ 1
catch (int) {
try {
}
0
void foo(int arg) {
try {
if (arg > 999) throw -100; }
catch (int x) {
cout << "error!" << endl; }
}
0
thanks all for your supports
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
- 1
thanks all