Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > friend sibling class nested in derived class problem in gcc 4.0

Reply
Thread Tools

friend sibling class nested in derived class problem in gcc 4.0

 
 
Tomas Sieger
Guest
Posts: n/a
 
      12-16-2005
Hi all,
I'm in doubt with the following code:

class Base {
public:
class Nested {};
};
class Derivedublic Base {
public:
class Nested {
public:
void m();
};
class AnotherNested {
friend class Nested; // gcc 4.0.2 takes it as 'Base::Nested'
//friend class Derived::Nested; // this is needed in order to
be compiled by gcc 4.0.2
#line 14
AnotherNested() {}
};
};
void Derived::Nested::m() {
#line 18
Derived::AnotherNested instance;
}

should the first friend decl refer to Base::Nested or Derived::Nested?

The code is refused e.g. by gcc 4.0(.0,.2):
a.cpp: In member function 'void Derived::Nested::m()':
a.cpp:14: error: 'Derived::AnotherNested::AnotherNested()' is private
a.cpp:18: error: within this context
because gcc 4 takes for granted the friend refers to Base::Nested.
However, e.g. gcc 3.4 takes it as Derived::Nested.
Declaring the friend the second way:
friend class Derived::Nested;
works in gcc 4.0, but I see two issues with it:
1) it uses not-yet-fully-declared class Derived
2) some compilers (e.g. VC 6.0) can't compile it (because of the
Derived incompletness)

I've not succeeded tracking this issue neither in the C++ standard nor
in gcc.
best regards
Tomas Sieger

 
Reply With Quote
 
 
 
 
Tomas Sieger
Guest
Posts: n/a
 
      12-20-2005
FYI: this has been confirmed as bug in gcc:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25492
regards
Tomas Sieger

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Nested friend class in nested template problem tonvandenheuvel@gmail.com C++ 3 12-07-2007 03:02 PM
Derived::Derived(const Base&) and Derived& operator=(const Base&) developereo@hotmail.com C++ 1 05-23-2007 01:44 PM
Derived::Derived(const Base&) and Derived& operator=(const Base&) developereo@hotmail.com C++ 1 05-23-2007 12:07 AM
Is nested class automatically friend of class that it is nested in? request@no_spam.com C++ 5 09-25-2006 08:31 AM
how to find not the next sibling but the 2nd sibling or find sibling "a" OR sinbling "b" localpricemaps@gmail.com Python 11 01-23-2006 07:04 PM



Advertisments