• 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: Adin Hunter Baber <email@hidden>
  • Date: Sat, 31 Dec 2005 07:56:56 -0600


On 2005 Dec 30, at 1:12 PM, 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.

Thanks,
Nick

warning: 'virtual void A::foo(a)' was hidden
warning:   by 'virtual void B::foo(b)'

struct a
{
int i;
};

struct b
{
double x;
};

class A
{
virtual ~A() {};
virtual void foo(a) {};
virtual void foo(b) {};
};

class B : public A
{
// virtual void foo(a) {};
virtual void foo(b) {};
};


Others have pointed out why you are having a problem.  Here's away to avoid the problem:

class A
    {
    public:
        virtual ~A();
       
        void foo(a);
        void foo(b);
    private:
        virtual void foo_a_impl(a);
        virtual void foo_b_impl(b);
    };

void A::foo(a)
    {
    foo_a_impl(a);
    }
void A::foo(b)
    {
    foo_b_impl(b);
    }
   
class B
    {
    public:
        // ...
    private:
        virtual void foo_a_impl(a);
        virtual void foo_b_impl(b);
    };

Class B will inherit the public foo()'s, and will automatically call the correct private virtual implementation functions.  You no longer need to worry about the hidden functions issue.


Adin Hunter Baber
email@hidden



 _______________________________________________
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: Nick Nallick <email@hidden>
References: 
 >Hidden Overloaded C++ Virtual Function (From: Nick Nallick <email@hidden>)

  • Prev by Date: What is an Applescript document type project
  • Next by Date: Play Sound when done Compiling?
  • Previous by thread: Re: Hidden Overloaded C++ Virtual Function
  • Next by thread: Re: Hidden Overloaded C++ Virtual Function
  • Index(es):
    • Date
    • Thread