- 2
Exception C++
Fill in the missing part to catch every kind of exception in the catch block. try { // ...some code } catch ( ) { }
5 Respostas
+ 6
...
+ 3
try{
// ...
} catch (...) {
// ...
}
+ 2
Answer is ...
Just type ...
+ 1
...
0
Here is an example of the code form the exeption challenge put in use:
#include <iostream>
using namespace std;
int main() {
string name;
cin >> name;
try {
if (size(name)<4 || size(name)>20)
{
//cout << "Invalid";
throw 99;
}
if (!(size(name)<4 || size(name)>20))
{
cout <<"Valid"<<endl;
}
else
{cout <<""<<endl;
}
}
//we must specify the data type of the exeption when we throw it
catch(int x) {
cout << "Invalid";
}
return 0;
}