Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Hidden Virtual Functions



On 5/23/05, William Rector <email@hidden> wrote:
> I'm using Xcode 2.0 OS X 10.4.1 and moving several C++ projects from CW 9.5
> to Xcode.
> 
> 
> I am getting a bunch of warnings of hidden virtual functions and am
> wondering if Xcode is really unabled to match the right virtual function or
> the message is bogus.
> I have a base class with the following:
> virtual    SInt32        ProcessKeyword(char* szKey,char* szParams);
> virtual    SInt32        ProcessKeyword(UInt32 nKeyCode,char* szParams);
> I keep getting 'warning: 'virtual SInt32
> CTFReader::ProcessKeyword(char*,char*) was hidden.
> I guess I will find out soon when I get past my libraries to one of my
> applications.

I am assuming that you have something like:

class Base
{
virtual    SInt32        ProcessKeyword(char* szKey,char* szParams);
virtual    SInt32        ProcessKeyword(UInt32 nKeyCode,char* szParams);
};

class Derived : Base
{
//Only overloading one of them
virtual    SInt32        ProcessKeyword(char* szKey,char* szParams);
};

If this is so, then the warning is correct, and it is an error if you
do something like:
    Derived d;
    d.ProcessKeyword(25,"asdf");

But this is still OK:
    Base *b = new Derrived;
    b->ProcessKeyword(25,"asdf");

You can fix this by either:
1) Adding "using Base::ProcessKeyword;" like so:
class Derived : Base
{
using Base::ProcessKeyword;
virtual    SInt32        ProcessKeyword(char* szKey,char* szParams);
};
2) or making sure that you implement all overloads of ProcessKeyword
in the derrived class.

-- 
Clark S. Cox III
email@hidden
http://www.livejournal.com/users/clarkcox3/
http://homepage.mac.com/clarkcox3/
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/xcode-users/email@hidden

This email sent to email@hidden

References: 
 >Hidden Virtual Functions (From: William Rector <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.