I was going through C++ FAQ 2nd Edition, FAQ 9.04- What is an exception specification?
.
There,it is mentioned that if we throw an unexpected exception from a function whose signature specifies a set of predefined exception types, it is supposed to call unexpected()->terminate()->abort()
.
But my program catches the unexpected exception and is not abort()
ing it, why?
#include<iostream>
using namespace std;
class Type1{};
class Type2{};
class Type3{};
void func() throw(Type1, Type2)
{
throw Type3();
}
int main()
{
try{
func();
}
catch (Type1 &obj1)
{
cout << "Type1 is caught" << endl;
}
catch (Type2 &obj2)
{
cout << "Type2 is caught" << endl;
}
catch (Type3 &obj3)
{
cout << "Type3 is caught" << endl;
}
}
Here I am getting the output Type3 is caught
which should not have occured.
IDE: VS2013