It's all in this example
class MyException: std::runtime_error // note, there is no public keyword in inheritance
{
public:
MyException(const std::string & x)
: std::runtime_error(x)
{}
};
int main( )
{
try
{
throw MyException("foo");
}
catch (std::exception & e )
{
std::cout << "catched std exception: " << e.what() << std::endl;
}
catch (...)
{
std::cout << "catched ... " << std::endl;
}
}
It writes on stdout string "catched ...". But, if I change inheritance to public as class MyException : public std::runtime_error, it works as expected (for me) and writes "catched std exception: foo"
What part of the c++ standard requires such behavior? And why? In what cases such behavior could be useful?