Hiding class pointers -- was it a good idea?

Walter Bright newshound1 at digitalmars.com
Thu Aug 16 01:40:51 PDT 2007


James Dennett wrote:
> Walter Bright wrote:
>> That's known as the 'slicing' problem. It's pernicious in that it can be
>> extremely hard to expose via testing or code reviews, yet will expose
>> the program to unpredictable behavior.
> 
> It's trivially detected by various automated tools, which
> can flag any non-abstract base class.  (Such classes almost
> invariably indicate bad design in any case.)  Clearly it
> would be simple for a compiler to detect when a concrete
> class was used as a base class.  There's no need to remove
> value semantics in order to solve this problem; it's
> something of a sledgehammer solution.

That's true if you agree with the notion that only abstract classes 
should be used as base classes, which I do not agree with.



More information about the Digitalmars-d mailing list