Re: Hidden Overloaded C++ Virtual Function
Re: Hidden Overloaded C++ Virtual Function
- Subject: Re: Hidden Overloaded C++ Virtual Function
- From: Philippe Casgrain <email@hidden>
- Date: Wed, 4 Jan 2006 12:03:21 -0500
Le 05-12-30 à 14:26, Marshall Clow a écrit :
At 12:12 PM -0700 12/30/05, Nick Nallick wrote:
There's probably something subtle here that I don't understand,
but can somebody tell me why gcc4 is telling me that A::foo(a) is
hidden by B::foo(b) when I comment out B::foo(a) below? This
seems like an overenthusiastic warning to me.
Nope - gcc is correct.
I believe that hiding is done by function name, not by signature.
if you override any of the "foo"s, then you hide all of them.
I have been following this thread with interest and have a follow-up
question.
What if you *want* to hide the base class implementation? Is there
any way to tell gcc that's what you want for this class, other than
turning the warning off?
I could play "Mr. Compiler" and do this, which explicitely calls
B::foo() when calling foo(int), but that can get tiring.
class A
{
public:
virtual void foo(int i);
};
class B: public A
{
public:
void foo(int i) { return B::foo(i); };
void foo(float f);
};
Plus, I may want the compiler to stop me from using B::foo(int),
which it will do if I don't declare foo(int) in B.
So, is there any way to do that besides turning off the warning? Is
there a pragma or something?
Philippe _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden