Warning about overrides hiding base class methods ?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I am getting an odd error from gcc 3.4.3.
The example code below generates the following error:

  main.cpp:6: warning: `virtual void A::fn(float&)' was hidden
  main.cpp:19: warning:   by `virtual void Y::fn(int&)'

Why ? A::fn(float) should not be hidden, because Y::fn(int) and its inherited
Y::fn(float) have different signatures.
If Y had a non-virtual fn(float), that *would* hide the A::fn(float) but not
A::fn(int).

I know that usually gcc warnings have a very good explanation behind them, but
this time I can't see what it is trying to tell me. Can someone explain ?!

TIA.

---- code ----

class A
{
public:
    virtual void fn(int &) {}
    virtual void fn(float &) {}
};

class X : public A
{
public:
    virtual void fn(int &) {}
    virtual void fn(float &) {}
};

class Y : public A
{
public:
    virtual void fn(int &) {}
};

---- end of code ----

--
Matthew JONES
http://www.tandbergtv.com/


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux