From: Peter Dimov (pdimov_at_[hidden])
Date: 2004-12-30 19:48:02
Mathew Robertson wrote:
>>>> Yeah, geez. Single-rooted hierarchies of diverse functionality
>>>> with a root class called "object" were discredited long ago,
>>>> weren't they?
>>> I am not suggesting a single-rooted heirarchy for *all* the classes
>>> as that would be stupid. MFC does it to support their own version
>>> of RTTI, memory leak tracking, etc. Java does it because it doesn't
>>> have templates. .NET has it because it treats every object as a COM
>> Python does it too. It's not neccessarily wrong for other languages;
>> just C++.
> hmm.... If C++ had implemented an 'Object' back in 1980, then "single
> rooted heirachy"s wouldn't be questioned...
We'd still be using C in that case. ;-)
Bad single-rooted hierarchies are bad in principle; it doesn't depend on
language. The problem occurs when the base class acquires functionality that
90% of the descendants have. The other 10% are forced to implement something
that they do not support. Over time, this can lead to "spectacular" designs.
All of the above examples do not fit this description; the root "object" is
simply what constitutes an object in that particular language. Since in C++
everything can be an object, the root class is "void".
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk