From -6061308466628361412
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 109fba,ac06fef48c3c04df
X-Google-Attributes: gid109fba,public
X-Google-Thread: f78e5,ac06fef48c3c04df
X-Google-Attributes: gidf78e5,public
X-Google-ArrivalTime: 1995-01-24 18:24:35 PST
Path: pad-thai.cam.ov.com!bloom-beacon.mit.edu!gatech!swrinde!pipex!uunet!zib-berlin.de!gs.dfn.de!tubsibr!ti953017
From: ti953017@rzcipa01.rz.tu-bs.de (Andreas Rossberg)
Newsgroups: comp.lang.c++,comp.std.c++
Subject: Re: friends and local classes
Date: 24 Jan 1995 13:19:56 GMT
Organization: TU Braunschweig, FRG
Lines: 43
Distribution: world
Message-ID: <3g2ups$bhu@ra.ibr.cs.tu-bs.de>
References: <3frgln$deh@senator-bedfellow.MIT.EDU> <3froli$gss@news.panix.com> <3fskgs$qsg@engnews2.Eng.Sun.COM> <JGEALOW.95Jan22230221@mtl.mit.edu>
NNTP-Posting-Host: rzcipa03.rz.tu-bs.de
Xref: pad-thai.cam.ov.com comp.lang.c++:70773 comp.std.c++:9232


A similar but more important issue are nested classes:

	class A
	{
	private:
		typedef int T;
		void f();

		class B
		{
		public:
			T t;				// error
			void g(A &a) { a.f(); }		// error
		};
	};


By default, the nested class B has no access to private members of the outer
one. To me, this seems illogical, because B clearly is some kind of member of
A after all.

It also is a nuisance since such access is frequently needed for private
implementation classes (look at the STL, for example). And the only way to
achieve it is writing

	class A
	{
	private:
		class B;
		friend class B;
		class B { /* ... */ };
	};

This is tedious and even used to be illegal.

Why are the rules that way? Could anybody give me a hint? However, IMO, the
language should at least allow the terse notion of

		friend class B { /* ... */ };


	- Andreas Rossberg


