• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Hidden Overloaded C++ Virtual Function
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: Hidden Overloaded C++ Virtual Function
      • From: Scott Ribe <email@hidden>
  • Prev by Date: Re: Apple USBSimple Example & Rosetta
  • Next by Date: Re: Hidden Overloaded C++ Virtual Function
  • Previous by thread: Re: Build settings
  • Next by thread: Re: Hidden Overloaded C++ Virtual Function
  • Index(es):
    • Date
    • Thread