In the following program abort method is called even when I have got the applicable catch statement. What is the 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 with try-catch\n";
}
When I run the program I only get the first statement inside try displayed and then I get this error:

Why does abort get called even when I am handling string exception?
Quite simple really!
You threw
char const*, but do not have a matchingcatchfor it.Did you mean
throw std::string("...");?