exception question help!!
why do I get a compilation error in the code below?
what do I do to fix the problem?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
|
#include <iostream>
#include <exception>
using namespace std;
int main() {
try {
throw 3.14;
}
catch(double x) {
x *= 2;
}
cout << x;
return 0;
}
|
1 2 3 4
|
catch(double x) {
x *= 2;
}
cout << x; // in this scope x is undeclared. cout it inside catch block
|
Last edited on
Topic archived. No new replies allowed.