From -3646915219251116292 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f78e5,7961205d5764d0b X-Google-Attributes: gidf78e5,public From: Francis Glassborow Subject: Re: A suspect bug in Visual C++ Date: 1998/11/29 Message-ID: #1/1 X-Deja-AN: 416632339 Approved: stephen.clamage@sun.com (comp.std.c++) References: <8767c1s375.fsf@pot.cnuce.cnr.it> Organization: Southfield Microcomputer SS Mime-Version: 1.0 Reply-To: Francis Glassborow Newsgroups: comp.std.c++ Originator: clamage@taumet I find this an interesting question. To what is f() being granted access? The private interface of class B. But this is not the same as the private interface of class A. I think you have to declare friend void f() in both A and B. Can anyone quote the Standard to justify accepting the code as written? In article <8767c1s375.fsf@pot.cnuce.cnr.it>, Francesco Potorti` writes >Hi, this is observed behaviour on VC++ 4.0, 5.0, 6.0. The following >snippet of code compiles without errors under egcs (as it should, in my >opinion), while it generates an error when compiled by VC++. >--------------------------- >class A { > class B { > struct C {}; > friend void f(); > }; >}; >void f() { > A::B::C *p; >} >--------------------------- >--> baco_VC.cpp(9) : error C2248: 'C' : > cannot access private struct declared in class 'A::B' >I'd like to hear opinions about whether this is indeed a compiler bug or >else why ever the VC++ compiler classifies this syntax as an error. Francis Glassborow Chair of Association of C & C++ Users 64 Southfield Rd Oxford OX4 1PA +44(0)1865 246490 All opinions are mine and do not represent those of any organisation [ 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://reality.sgi.com/austern_mti/std-c++/faq.html ]