[Zope3-dev] I've changed my mind about inheritence of interfacedeclarations

Tres Seaver tseaver@zope.com
12 Mar 2003 14:47:30 -0500


On Wed, 2003-03-12 at 14:35, Tim Peters wrote:
> [Tres Seaver]
> > ...
> > While very few C++ programs make significant use of non-public
> > inheritance, Stroustroup expected it to be common:  the default is
> > private!
> 
> Well, if it were public, "class" and "struct" would mean exactly the same
> thing in C++.  I don't think Stroustrup is shy about adding methods to
> things declared as structs.

The major difference between 'class' and 'struct' is that 'struct' makes
the default "member access mode" public, while class makes it private.
You are correct that Stroustroup (and many others) add methods to
structs;  in fact, before the language supported namespaces, I
frequently saw struct's whose only "members" were classes and helper
functions!

Having the default inheritance mode be private was perhaps a "foolish
consistency", given how infrequently private inheritance is used.

> WRT protected, in his "The Design & Evolution of C++" book, Stroustrup said
> the introduction of protected was a mistake, a case of letting "good
> arguments" override his design sense.  He noted with chagrin that the fellow
> who insisted protected was vital for his company's continued use of C++ said
> a few years later that it turned out they didn't use it.  It did supply an
> entertaining writing task for the std committee, though <wink>.

I can certainly say I've never seen protected inheritance used
effectively "in the wild";  I do recall several designs in which the
ability to distinguish the "client" API ("public" methods) from the
"derived class" API ("protected" methods) was a big win.

Tres.
-- 
===============================================================
Tres Seaver                                tseaver@zope.com
Zope Corporation      "Zope Dealers"       http://www.zope.com