If I am catching BaseException will this also catch exceptions which derive from BaseException? Does exception handling care about inheritance, etc, or does it only match the exact exception type being caught?
class MyException {
...
};
class MySpecialException : public MyException {
...
};
void test()
{
try {
...
}
catch (MyException &e) {
//will this catch MySpecialException?
}
}
It’s easy to explain with code: http://ideone.com/5HLtZ
output:
catch 1
catch 2