🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c++
Article #468

Re: Protected base classes

#468
From: Tony L. Hansen
Date: Fri, 31 Aug 1990 18:32
51 lines
2431 bytes
< Recently, I tried to use a protected base class, like this:
< class A { ... };
< class B: protected A { ... };
< To my surprise, my compiler (based on CFront 2.0) refused to compile this.
< The ARM doesn't seem to be clear about this: The syntax seems to allow it,
< but the text and examples don't mention it.
< My question is: If protected base classes are indeed illegal, why are they
< and what speaks against adding them to C++ ?

The introduction of protected base classes occurred this year as part of the
1990 C++ definition. The AT&T 2.1 C++ Reference Manual, and subsequently The
Annotated C++ Reference Manual (E&S), documents its introduction.

However, NO compiler currently implements protected base classes, not even
AT&T's 2.1. Also, the exact semantics have NOT been cast in stone, although
it's unlikely that they will differ much from the following description:

The visibility of the members of a base class are "capped" at the level of
the access specifier given for the base class. For the following example:

	class base
	{
	public:   int bpublic;
	private:  int bprivate;
	protected:int bprotected;
	};

	class derived :		class derived :		class derived :
	    public base		    protected base	    private base
	{			{			{
	    ...			    ...			    ...
	};			};			};

the visibility of the different base members are adjusted as follows for the
various members of base using the different access specifications:

  access spec:	public		    protected		private
  ----------------------------------------------------------------
  bpublic:	public		    protected		private
  bprotected:	protected	    protected		private
  bprivate:	not accessible	    not accessible	not accessible

I hope this helps.

< I hope this question is not inappropriate for this newsgroup.

I'd say it's perfectly appropriate for this newsgroup.

					Tony Hansen
				att!pegasus!hansen, attmail!tony
				    hansen@pegasus.att.com
Technical Details
Message-ID: <5014@pegasus.ATT.COM>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!watserv1!watmath!att!dptg!pegasus!hansen
References: <5026@neptune.inf.ethz.ch>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!watserv1!watmath!att!dptg!pegasus!hansen
From: hansen@pegasus.ATT.COM (Tony L. Hansen)
Newsgroups: comp.std.c++
Subject: Re: Protected base classes
Summary: yes, protected base class are there, but no one implements them yet
Message-ID: <5014@pegasus.ATT.COM>
Date: 31 Aug 90 18:32:06 GMT
References: <5026@neptune.inf.ethz.ch>
Reply-To: hansen@pegasus.ATT.COM (Tony L. Hansen)
Organization: AT&T Bell Labs NJ USA
Lines: 51