On Mon, 2004-08-23 at 15:04, Jonathan Turkanis wrote:
1) Use virutal inheritance. I see the example and can understand why its wrong I just do not understand how to fix it.
I believe in the example the fix is to use virtual inheritance in the definitions of my_exc1 and my_exc2, so that later someone can derive from both. Using virtual inheritance in the definition of your_exc3 doen't help. I see that this advice is not followed consistently within boost (Robert Ramey's serialization library is the only case I can find). But it's still good advice, I think.
To do virtual inheritance I was under the belief that the base class had only pure virtual methods. Each subclass then implements the virtual methods. Is this what was intended or am I misunderstanding the term virtual inheritance?
Often you can get away with:
class Data_Exception : public std::exception { public: Data_Exception(int code) : code_(code) { } virtual const char* what() const throw() { [return result of looking up code in a table of error messages.] } private: int code; };
So each class has a predefined table of int/string pairs. This table should be a static member of this class because there is not need to have multiple instances. Can you use a std::map or sgi hash_map to construct the table? Stephen -- Email: storri@torri.org