Boost logo

Boost :

From: Dave Gomboc (dave_at_[hidden])
Date: 2003-08-24 19:17:13

> Maybe I am not seeing this from the right perspetive, but wouldn't a
> design guideline be not to use multiple inheritance at all in an exception
> hierarchy? I do not see any reason that any exception would have an IS-A
> relationship with any two parent classes. I view an exception of being a
> very specific error, but multiple inheritance implies that the exception
> simultaneously two types of errors.

Quoting from Section 14.2.2, The C++ Programming Language, 3rd edition
(Bjarne Stroustrop):

Not every grouping of exceptions is a tree structure. Often, an exception
belongs to two groups. For example:

class Netfile_err : public Network_err, File_system_err { /* ... */ };

Such a Netfile_err can be caught by functions dealing with network

[code snippet elided]

and also by functions dealing with file system exceptions:

[code snippet elided]

This nonhierarchical organization of error handling is important where
services, such as networking, are transparent to users. In this case, the
writer of [the code handling file system exceptions] might not even be aware
that a network is involved.


Boost list run by bdawes at, gregod at, cpdaniel at, john at