Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2006-06-01 18:49:48


Sebastian Redl <sebastian.redl_at_[hidden]> writes:

> Marsh J. Ray wrote:
>
>>Seems to me that, if the author is really set on using inheritance here,
>>integer should inherit from unsigned_integer, since integer can do
>>everything that an unsigned can do, but not vice-versa. Integer extends
>>unsigned with the ability to represent negative values and the result of
>>subtraction.
>>
>>
> No, that's not true. (See Scott Meyers, Effective C++, Item 35) If a
> signed integer IS-A unsigned integer, then all invariants of unsigned
> integer must hold true for signed integer - including the one about
> negative values. ("There's no such thing.")

IMO the whole idea of using inheritance here is so misguided in the
first place that which order you do it in is probably not worth
arguing about.

-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk