From -8613317381225637805
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: fc772,e4551d1072848803
X-Google-Attributes: gidfc772,public
X-Google-Thread: f78e5,e4551d1072848803
X-Google-Attributes: gidf78e5,public
X-Google-ArrivalTime: 2001-11-30 05:19:57 PST
Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news.uchicago.edu!vixen.cso.uiuc.edu!uwm.edu!rpi!not-for-mail
From: kensai@pacbell.net (Sean Kelly)
Newsgroups: comp.lang.c++.moderated,comp.std.c++
Subject: Re: Omitting the access specifier of a base class
Date: 30 Nov 2001 08:10:10 -0500
Organization: http://groups.google.com/
Lines: 39
Sender: cppmods@netlab.cs.rpi.edu
Approved: kuehl@fmi.uni-konstanz.de
Message-ID: <721ff0b.0111291627.59b46888@posting.google.com>
References: <3C051430.3AE0E9C2@bawi.org>
NNTP-Posting-Host: netlab.cs.rpi.edu
X-Auth: PGPMoose V1.1 PGP comp.std.c++
	iQBFAgUAPAb6NOEDnX0m9pzZAQE7+QGAgECbRpTfTOgf9DJta8UEm3+9kQIHeM7M
	9uek7GUtmeVV4/vWrswi/maqBiDr6LGf
	=n0Dg
X-Approved-For-Group: Fergus Henderson <fjh@cs.mu.oz.au> comp.std.c++
X-Original-Date: 30 Nov 01 03:17:00 GMT
X-Submission-Address: c++-submit@netlab.cs.rpi.edu
X-Auth: PGPMoose V1.1 PGP comp.lang.c++.moderated
	iQBVAwUAPAeFL0HMCo9UcraBAQEX6QIAnmbu0z7VM95lB33Eopq5TCd1vjytUcj9
	3Q9JdYslHmT228pwFdSQRwUUSU5e4G1ly0wH13LsPMIGedDyDKcIoA==
	=fym/
Xref: archiver1.google.com comp.lang.c++.moderated:31519 comp.std.c++:8380

Sungbom Kim <musiphil@bawi.org> wrote in message news:<3C051430.3AE0E9C2@bawi.org>...
> In the absence of an access specifier for a base class,
> - 'public' is assumed when the derived class is declared 'struct', and
> - 'private' is assumed when the derived class is declared 'class'.
> 
> I wonder what the rationale is for allowing the omission, and
> for giving such defaults if omission is allowed.
> 
> In particular I supposed that it would have been better to give a
> default of 'public' in either case, since public inheritance is much
> more common and represents the IS-A relationship that the most typical
> kind of inheritance expresses.

You're confusing inheritance with access.  The rule states that
members of a struct are public unless declared otherwise and members
of a class are private unless declared otherwise.  The reason for
struct members defaulting to public is simple -- it was neccessary for
backwards-compatibility with C code.  The reason for class members
being private is equally straightforward -- the idea was to promote
encapsulation.  What has always bugged me was that in C++ we end up
having two specifiers for the exact same thing.  I grant that the each
label is appropriate for the access rules, but inheritance heirarchies
incorporation both seems messy to me.  I'd rather just use class or
struct everywhere and get rid of the other label entirely.

> Wouldn't there be any possibility that the next standard would
> declare the omission of the access specifier to be deprecated,
> as was the case with implicit int for function return types?

Not in this case, because again, the C++ compiler would not be able to
compile C code containg struct declarations (as C does not have access
specifiers).  Whether C-compatibility is a desirable feature to
continue to support, however, is another discussion.
---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html                ]



