c++ - why is abort method called? -
in following program abort
method called when have got applicable catch statement. reason?
#include <iostream> #include <string> using namespace std; int main() { try { cout << "inside try\n"; throw "text"; } catch (string x) { cout << "in catch" << x << endl; } cout << "done try-catch\n"; }
when run program first statement inside try
displayed , error:
why abort
called when handling string
exception?
quite simple really!
you threw char const*
, not have matching catch
it.
did mean throw std::string("...");
?
Comments
Post a Comment