473,241 Members | 1,492 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,241 software developers and data experts.

friend sibling class nested in derived class problem in gcc 4.0

Hi all,
I'm in doubt with the following code:

class Base {
public:
class Nested {};
};
class Derived:public 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

Dec 16 '05 #1
1 2091
FYI: this has been confirmed as bug in gcc:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25492
regards
Tomas Sieger

Dec 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

17
by: Asfand Yar Qazi | last post by:
Basically this: //file 'B.hh' class B { protected: void f() {} }; //file 'C.hh'
3
by: cman | last post by:
#include <stdio.h> class Base { public: Base() { printf("Base()\n"); } ~Base()
5
by: Charles Jamieson | last post by:
I have two classes, a base class, CBaseClass, and its derived class, CDerivedClass. I overload the insertion operator as ostream& operator << ( ostream&, CBaseClass& ); Then I define an...
3
by: Alicia | last post by:
Hello, I am trying to figure out how to call an overloaded operator<< inherited from a base class. #ifndef PHONECALL #define PHONECALL #include "time.h" #include "interval.h"
1
by: question | last post by:
I want to know incase there is any performance difference or overhead in calling a base class method and a derived class method. Basically I am talking about simple method that is not overridden...
8
by: Mike C# | last post by:
Suppose I have a base class "foo". Another class, "bar" derives from it. Base class "foo" has a method called "rob_the_liquor_store()", and the inherited class "bar" overrides this method with one...
1
by: Rahul | last post by:
Hi Everyone, I have the following code, class AA { public: int i; };
3
by: Edan | last post by:
I have a base class with protected members (`Base`). The function `MakeBase()` is a member function of another class, that returns a `Base` object initialized with private members of this class. Now...
0
by: brboLikus | last post by:
Hello everybody! My problem is somewhat strange since I can't think of any normal situation where one would like to do what I need, but here it goes. I need to somehow cast a base class to a...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.