Topic: Friendship of nested class
Author: "Alfred Kellner" <alfkellner@magnet.at>
Date: 1998/11/21 Raw View
sanjayp@ddi.com wrote:
> Hi, Consider this:
>
> class A {
> static void* foo;
> public:
class B; // <<< add fwd-decl class A::B
> friend class B;
> class B {
> public:
> void foobar() {
> foo;
A::foo; // <<< instead
> }
> };
> };
void * A::foo ; // storage <<< = NULL;
--ALfred
[ 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 ]
Author: sanjayp@ddi.com
Date: 1998/11/20 Raw View
Hi,
Consider this:
class A {
private:
static void* foo;
public:
friend class B;
class B {
public:
void foobar() {
foo;
}
};
};
Can someone tell me if A::B is a friend of A in the above case? I looked up
the standard but somehow it wasn't clear to me. As far as I understand the
friend declaration introduces class B in A's enclosing scope (non-class). So
A::B is not a friend of A? But gcc seems to accept the above code. Pls send
me a reply if you can.
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
---
[ 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 ]