:
class Matherr { /* ... */ virtual void vf(); };
class Overflow: public Matherr { /* ... */ };
class Underflow: public Matherr { /* ... */ };
class Zerodivide: public Matherr { /* ... */ };
void f() {
try {
g();
} catch (Overflow oo) {
} catch (Matherr mm) {
}
}
Here, the
Overflow
handler will catch exceptions of type
Overflow
and the
Matherr
handler will catch exceptions of type
Matherr
and of all types publicly derived from
Matherr
including exceptions of type
Underflow
and
Zerodivide. —
end example