class Base{
public:
void virtual abc() throw(int,double,long){}
};
class Derived:Base{
public:
//void abc(){}//1
//void abc() throw(double,int,long){}//2 does not matter on the sequence of the exceptions compared with the base?
};
As the derived override should be more restrictive, I expect the 2 is the right answer. However, I can get both 1 and 2 compiled (VS 2008), and I have warning saying exception specification is ignored in both cases. Any explanation on this?
Exception specifications were originally added to the language to allow compilers to optimize try/catch blocks a bit, but many compilers do nothing at all with exception specifications except
verify that you have them correct. I believe VS is one of those that completely ignores them (not
sure on this; not a windows developer).
Unless this is for academic purposes, my recommendation would be to not spend any time
learning about them, because in practice not only do many compilers not optimize, they
are simply a maintenance headache.