This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Overloaded functions in C++ (bug?)


> Yes, I know that I could work around by using `A::f()' in the first
> example and `::f()' in the second one. But I'd like to know whether
> current gcc behaviour is according to the standard or this is a genuine
> bug. I've read the FAQ, but I haven't found any reference to this kind
> of problem.

Thanks for your bug report. This is not a bug in g++, but in your
code. It is not mentioned in the FAQ, because it is a basic aspect of
C++; I recommend to read a book on C++. Methods in the derived class
hide methods in the base class. In standard C++, you could write

class B : public A {
public:
        using A::f;
	void f(int);
	void g();
};

which is currently not supported by g++; instead you can write

class B : public A {
public:
        void f(){A::f();}
	void f(int);
	void g();
};

Regards,
Martin

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]