* Warning about overrides hiding base class methods ?
@ 2005-08-01 10:50 Matthew Jones
0 siblings, 0 replies; only message in thread
From: Matthew Jones @ 2005-08-01 10:50 UTC (permalink / raw)
To: gcc-help
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/
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2005-08-01 10:50 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-08-01 10:50 Warning about overrides hiding base class methods ? Matthew Jones
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).