From -1950154565691226689
X-Google-Language: ENGLISH,ASCII
X-Google-Thread: 109fba,ac06fef48c3c04df
X-Google-Attributes: gid109fba,public
X-Google-Thread: f78e5,ac06fef48c3c04df
X-Google-Attributes: gidf78e5,public
X-Google-ArrivalTime: 1995-02-03 04:10:54 PST
Path: nntp.gmd.de!Germany.EU.net!zib-berlin.de!informatik.tu-muenchen.de!schuenem
From: schuenem@Informatik.TU-Muenchen.DE (Ulf Schuenemann)
Newsgroups: comp.lang.c++,comp.std.c++
Subject: Re: friends and local classes
Date: 3 Feb 1995 12:10:54 GMT
Organization: Technische Universitaet Muenchen, Germany
Lines: 79
Distribution: world
Message-ID: <3gt6ge$q3m@hpsystem1.informatik.tu-muenchen.de>
References: <FENSTER.95Jan24182929@ground.cs.columbia.edu> <3g5qc6$16p@news.cc.utah.edu>  <3g5rei$dl8@news.panix.com> <9502801.16190@mulga.cs.mu.OZ.AU>  <3glv86$dbg@hpsystem1.informatik.tu-muenchen.de>  <3gpb3n$nh4@booz.bah.com> <D3DF84.o8@cwi.nl>
NNTP-Posting-Host: hpbroy8.informatik.tu-muenchen.de
X-newsreader: xrn 7.00
Xref: nntp.gmd.de comp.lang.c++:89286 comp.std.c++:11362


In article <D3DF84.o8@cwi.nl>, olaf@cwi.nl (Olaf Weber) writes:
[..]
|> I think you misunderstood.  What Ulf means is that after
|> 
|> 	class C {
|> 		class N0 { ... };
|> 		class N1 { ... };
|> 		...
|> 	};
|> 
|> the members of C::N0 and C::N1 would have access to all members of C.
|> He did not mean that the private parts of C::N0 should be accessible
|> to C::N1 or vice versa.  

Exactly.

|> This seems much more reasonable to me than the current situation.

To give a long example:

class C {
	// we will look at usage of these 3 private members of C
	class N0 {
		static int	classvar;
		int		instvar;
	public:			N0	() {}
	};
	static int	classvar;
	int		instvar;

	// it's clear what members of C memberfunctions of C may access
	// (all ot them):
	static void	f(N0 & n0)
	{	N0	my_n0;	// OK: public member of C::N0
		N0::classvar++;	// ERROR: private member of C::N0
		n0.classvar++;	// ERROR: private member of C::N0
		n0.instvar++;	// ERROR: private member of C::N0
	}
	static void	g(C&c)
	{	C::classvar++;
		c.classvar++;
		c.instvar++;
	}

	// compare that to what members of C a memberclass of C may access:
	struct N1 {
		// interestingly, gcc allows the usage of memberclass N0
		// insinde N1 although it's private to C (*) (**)
		N0		* n0p;
		static void	f(N0 & n0)
		{	N0	my_n0;	// OK: public member of C::N0
			N0::classvar++;	// ERROR: private member of C::N0
			n0.classvar++;	// ERROR: private member of C::N0
			n0.instvar++;	// ERROR: private member of C::N0
		}
		// currently: N1 may not use membervariables of C::
		// because they are private (*)
		static void	g(C&c)
		{	C::classvar++;	// ERROR (*)
			c.classvar++;	// ERROR (*)
			c.instvar++;	// ERROR (*)
		}
	};
	...
};

(*) The idea is to clearly allow all members (including memberclasses)
of a class the usage of all other (including private) members of that class.

[ (**) I wonder if this an oversight (bug) of gcc ]


Ulf Schuenemann

--------------------------------------------------------------------
Ulf Sch�nemann
Institut f�r Informatik, Technische Universit�t M�nchen.
email: schuenem@informatik.tu-muenchen.de


