Newsgroups: comp.std.c++
Path: utzoo!utgpu!cunews!csi.uottawa.ca!news
From: hitz@sim5.csi.uottawa.ca (Martin Hitz)
Subject: protected derivation
Message-ID: <1991Apr23.030507.17185@csi.uottawa.ca>
Summary: syntax but no semantics defined for class D: protected B ?
Keywords: access specifiers, derivation
Sender: news@csi.uottawa.ca
Nntp-Posting-Host: sim5
Organization: University of Ottawa
Date: Tue, 23 Apr 91 03:05:07 GMT

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)
