
Topher Cooper wrote:
<>
The problem seems to me to be the idea that it inherits from integer -- an almost classic example of misuse of inheritance. Pardon me if I lost the thread somewhere but that seems to be what is being proposed.
As others have said, inheritance should represent ISA both in interface and conceptually. If unsigned_integer followed this relationship than there would be no argument here -- the negative of an unsigned_integer would be clearly and unambiguously defined -- it just wouldn't happen to be an unsigned_integer. But that seems to eliminate the point of having a separate unsigned_integer type. Inheriting unsigned_integer from integer means that I can never be sure that negating an integer (which might actually be an unsigned_integer) is a reasonable thing to do. VERY BAD DESIGN.
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. - Marsh