Re: virtual method hidden
Re: virtual method hidden
- Subject: Re: virtual method hidden
- From: Steve Mills <email@hidden>
- Date: Thu, 8 Dec 2005 15:24:24 -0600
On Dec 8, 2005, at 15:15, Cameron Hayne wrote:
On 8-Dec-05, at 2:29 PM, Steve Mills wrote:
class fFolderWatcher {
public:
virtual OSErr WatchThisFolder(const short vrn, const long id);
virtual OSErr WatchThisFolder(const FolderSpec& fold);
};
And a subclass of that:
class dGraphicsFolderWatcher : public fFolderWatcher {
public:
virtual OSErr WatchThisFolder(const short vrn, const long id);
};
The warning is that the base class method is being hidden by the
subclass method:
fFolderWatcher.h:56: warning: 'virtual OSErr
fFolderWatcher::WatchThisFolder(const FolderSpec&)' was hidden
dFolderWatchers.h:29: warning: by 'virtual OSErr
dGraphicsFolderWatcher::WatchThisFolder(short int, long int)'
I'm just sending this to you - not to the list.
I'll reply back to the list too in case someone knows more than I do
about this.
I agree that it seems that the warning is wrong - it is mentioning
the wrong method.
However it seems clear that you *are* hiding the other base class
method.
I'm not sure why you would want to do that.
In other words, I would just fix your code and not worry about the
bug in the warning message.
But it's *not* hiding the base class method, it's simply overriding
one of them. I had another instance where a base class method really
was being hidden:
class base1 {
public:
virtual void blah(vector<long>* a);
};
class base2 {
public:
virtual void blah(vector<long>* a, bool b = true);
};
class sub : public base1, public base2 {
public:
virtual void blah(vector<long>* a);
};
This was a problem here:
void something(void)
{
sub s;
vector<long> v;
s.blah(&v);
}
In that it isn't clear if it's calling the base1 method or if it's
calling the base2 method with the default value for the 2nd parm. But
the 2 methods in my previous example have no default values, and it's
really clear that the 2 are quite different.
Steve Mills
Drummer, Mac geek
http://sjmills5.home.mchsi.com/
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
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