Boost logo

Boost Users :

From: Jonathan Turkanis (technews_at_[hidden])
Date: 2004-08-23 15:57:35


"Stephen torri" <storri_at_[hidden]> wrote in message:

> 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?

Yes. See http://tinyurl.com/5sgv8 [25.9].

> > 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?

Yes. But if you constuct the table on first use, and the purpose of
the table is partly to avoid running out of memory when constructing
exceptions, it's probably better to use a built-in array.

> Stephen

Jonathan


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net