From 7318094683256428040
X-Google-Thread: f78e5,f6130266038a8c4d
X-Google-Attributes: gidf78e5,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: jhyslop@ieee.org (Jim Hyslop)
Newsgroups: comp.std.c++
Subject: Re: Private Methodes declared outside of the class
Date: Thu, 19 Aug 2004 06:16:57 GMT
Lines: 35
Sender: mail2news@demon.net
Approved: fjh@cs.mu.oz.au (Fergus Henderson , moderator of comp.std.c++)
Message-ID: <4124228F.6000406@ieee.org>
References: <2oblfaF8nds3U1@uni-berlin.de> <_p6Uc.1281$g%5.16328@news2.e.nsc.no> <41211964$0$73936$14726298@news.sunsite.dk> <KmgUc.1340$g%5.17394@news2.e.nsc.no> <41238b91$0$73937$14726298@news.sunsite.dk>
NNTP-Posting-Host: news.news.demon.net
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: news.demon.co.uk 1092896222 29994 158.152.254.254 (19 Aug 2004 06:17:02 GMT)
X-Complaints-To: abuse@demon.net
NNTP-Posting-Date: Thu, 19 Aug 2004 06:17:02 +0000 (UTC)
X-Robomod: STUMP, ichudov@algebra.com (Igor Chudov)
X-User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.4.1) Gecko/20031008
X-Spam-Checker-Version: SpamAssassin 2.64-mulga_r1 (2004-01-11) on 
	mulga.cs.mu.OZ.AU
X-Spam-Status: No, hits=-4.9 required=5.0 tests=BAYES_00 autolearn=ham 
	version=2.64-mulga_r1
X-Accept-Language: en-us, en
X-Received: (from fjh@localhost)
	by mulga.cs.mu.OZ.AU (8.12.10+Sun/8.12.9/Submit) id i7J6GvCc005098;
	Thu, 19 Aug 2004 16:16:57 +1000 (EST)
X-Path: comp-std-cpp-robomod!not-for-mail
X-Spam-Level: 
X-Delivered-To: std-c++@ucar.edu
X-Authentication-Warning: mulga.cs.mu.OZ.AU: fjh set sender to devnull@stump.algebra.com using -f
X-Newsgroups: comp.std.c++
Path: g2news1.google.com!news2.google.com!proxad.net!news.cs.univ-paris8.fr!news.zanker.org!news.amigo.co.uk!news.clara.net!wagner.news.clara.net!194.159.246.34.MISMATCH!peer-uk.news.demon.net!kibo.news.demon.net!news.demon.co.uk!demon!stump.algebra.com!devnull
Xref: g2news1.google.com comp.std.c++:1840

Thorsten Ottosen wrote:
> hm...in the code presented earlier I would say friendship is needed.
Depends on your compiler :=)

Recapping the code in question:
 > class A
 > {
 >  private:
 >    int x;
 >
 >  class Impl;
 >  friend class Impl;

It is not possible to write a well-formed declaration that allows 
A::Impl access to A's private members. 11.4 para 1 states "A friend of a 
class is a function or class that is not a member of the class ...." 
Impl *is* a member of A, therefore A cannot grant it friendship.

Obviously, that's a mistake in the standard. Some compilers get around 
the mistake by allowing the friend declaration, some get around it by 
implicitly declaring nested classes friends.

DR 45 addresses this by allowing Impl access to all members to which A 
has access (this has the effect of making friendship transitive).

-- 
Jim


---
[ 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.jamesd.demon.co.uk/csc/faq.html                       ]



