hitz@sim5.csi.uottawa.ca (Martin Hitz) (04/23/91)
Recently, I came across page 196 of the ARM where the syntax of an
<access-specifier> for base classes in the definition of derived
classes is given:
<access-specifier>:
private
protected
public
However, there is no mention of the semantics of the protected keyword
in this context, especially not in section 11.2 (pages 242ff).
I tried
class B {};
class D : protected B {};
but it was not accepted by g++ nor by Zortech.
I could imagine some use for this construction, however. A class D could
decide to grant access to formerly public members of B to its (D's)
decendants, but not to ordinary clients. I.e., protected could "make"
public B members protected D members, just like public leaves them
public and private makes them private. Protected members of B could
probably stay protected by "protected derivation".
I suggest either to adopt such a rule or to remove protected from the
corresponding syntax.
Martin Hitz (hitz@csi.uottawa.ca)landauer@morocco.Eng.Sun.COM (@morocco.eng [Doug Landauer]) (04/25/91)
> [The] <access-specifier> for base classes in the definition of derived > classes [ ... includes "protected" ... ] > However, there is no mention of the semantics ... > I suggest either to adopt such a rule or to remove protected from the > corresponding syntax. The latest Draft working paper accepted by X3J16 does describe the meaning of this construct; at also includes some examples showing its use. In other words, yes, it is expected that protected derivation will be ("always has been", say some) a part of the C++ language. -- Doug Landauer - Sun Microsystems, Inc. - Languages - landauer@eng.sun.com Matt Groening on C++: "Our language is one great salad."