Thread View: comp.std.c++
4 messages
4 total messages
Started by Matthias Ulrich Neeracher
Thu, 30 Aug 1990 13:14
Protected base classes
Author: Matthias Ulrich Neeracher
Date: Thu, 30 Aug 1990 13:14
Date: Thu, 30 Aug 1990 13:14
25 lines
1221 bytes
1221 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++ ?
I hope this question is not inappropriate for this newsgroup.
Matthias
-----
Matthias Neeracher mneerach@inf.ethz.ch
"I wouldn't recommend sex, drugs or insanity for everyone,
but they've always worked for me" -- Hunter S. Thompson
Re: Protected base classes
Author: Bjarne Stroustrup
Date: Fri, 31 Aug 1990 02:54
Date: Fri, 31 Aug 1990 02:54
4 lines
462 bytes
462 bytes
The summaries say it all.
Re: Protected base classes
Author: Tony L. Hansen
Date: Fri, 31 Aug 1990 18:32
Date: Fri, 31 Aug 1990 18:32
51 lines
2431 bytes
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
Re: Protected base classes
Author: Jim ADCOCK
Date: Tue, 04 Sep 1990 18:52
Date: Tue, 04 Sep 1990 18:52
20 lines
1228 bytes
1228 bytes
In article <5026@neptune.inf.ethz.ch> mneerach@c.inf.ethz.ch (Matthias Ulrich Neeracher) writes:
>
>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.
Existing compilers are not reliable indicators of the fine-grained details
of the standardization effort. E&S is. Compilers claiming "2.1"
compatibility may be pretty close to E&S.
>My question is: If protected base classes are indeed illegal, why are they
>and what speaks against adding them to C++ ?
My understanding is that protected base classes will be allowed.
Unfortunately, I cannot find the appropriate reference in E&S.
[Though I'm sure I read it somewhere....]
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads