This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Problem with virtual const
- From: John Love-Jensen <eljay at adobe dot com>
- To: Pierre Chatelier <pierre dot chatelier at club-internet dot fr>, MSX to GCC <gcc-help at gcc dot gnu dot org>
- Date: Fri, 21 Apr 2006 06:25:16 -0500
- Subject: Re: Problem with virtual const
Hi Pierre,
Since the two functions have the same name (even though different
signatures), B will hide A's other g().
Here's how you tell the compiler that you actually want A's g() to be
visible in B:
class B : public A
{
public:
virtual ~B() {}
virtual int g(int x) const {return x;}
using A::g;
};
This behavior is in the language intentionally. The rationale being (if I
recall correctly) is that for non-trivial projects it is desirable for the
compiler to flag situations where possible changes to the parent class
during on-going development may not yet be reflected in the child class.
HTH,
--Eljay