🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: friend class declaration and nested classe

#3302
From: Steve Clamage
Date: Wed, 07 Feb 1996 22:00
53 lines
1847 bytes
In article 1rp@fsuj01.rz.uni-jena.de,  mkt@isun04.inf.uni-jena.de (Tilo Koerbs) writes:

>	class X;

>	class Y {
>		class X {};
>		friend class ::X;  // error!!!
>	};

No, that example is OK.

>I watched the ARM and found out:
>	Section 11.4: "... All the functions of a class X can be
>		made friends of a class Y by a single declaration
>		using an 'elaborated-type-specifier' ('9.1):

>			class Y {
>				friend class X;
>				// ...
>			};"

>	'elaborated-type-specifier':
>		'class-key' 'class-name'
>		'class-key' 'identifier'
>		enum 'enum-name'

>	'class-key':
>		class
>		struct
>		union

>	'class-name':
>		'identifier'

The grammar in the ARM is not quite complete or correct. The draft standard says

	elaborated-type-specifier:
		class-key  ::[opt]  nested-name-specifier[opt] identifier
		enum  ::[opt]  nested-name-specifier[opt] identifier

So things like
	friend class ::X;
	friend class A::B::X;
are allowed by the syntax.

---
Steve Clamage, stephen.clamage@eng.sun.com


[ comp.std.c++ is moderated.  Submission address: std-c++@ncar.ucar.edu.
  Contact address: std-c++-request@ncar.ucar.edu.  The moderation policy is
  summarized in http://reality.sgi.com/employees/austern_mti/std-c++/policy.html
]
Technical Details
Message-ID: <4fb77t$qsq@engnews1.Eng.Sun.COM>
Path: arc1-ca.pugleaf.net!engnews1.Eng.Sun.COM!taumet!clamage
References: <4fa71q$1rp@fsuj01.rz.uni-jena.de>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!engnews1.Eng.Sun.COM!taumet!clamage
From: clamage@Eng.sun.com (Steve Clamage)
Newsgroups: comp.std.c++
Subject: Re: friend class declaration and nested classe
Date: 7 Feb 1996 22:00:25 GMT
Organization: Sun Microsystems Inc.
Approved: clamage@eng.sun.com (comp.std.c++)
Message-ID: <4fb77t$qsq@engnews1.Eng.Sun.COM>
References: <4fa71q$1rp@fsuj01.rz.uni-jena.de>
Reply-To: clamage@Eng.sun.com
NNTP-Posting-Host: taumet.eng.sun.com
Content-Type: text
X-Nntp-Posting-Host: taumet.eng.sun.com
Content-Length: 988
X-Lines: 48
Originator: clamage@taumet