• 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: virtual method hidden
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: virtual method hidden


  • Subject: RE: virtual method hidden
  • From: "David McCarthy" <email@hidden>
  • Date: Thu, 8 Dec 2005 17:03:40 -0500
  • Thread-topic: virtual method hidden

I'm sure that CW would also warn about it; that's where I first learned
about the concept. It's pretty easy to insert a "using" clause to avoid
the problem, hence my recommendation to google "rather annoying..."

-----Original Message-----
 On 2005-12-08 13:29, Steve Mills said:

>And a base class:
>
>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 don't see how this is possible, unless the compiler is
>deconstructing the FolderSpec into its parts, which just happen to be
>a short and a long. But why wouldn't it find the base class method
>that actually takes (short, long)?

What David said.  This is a warning gcc gives that CW does not, and I
came across it recently too.  From what I learned googling, one should
basically not override overloaded methods.  Or if you do, you have to
override all of them, ie your dGraphicsFolderWatcher needs to override
WatchThisFolder(const FolderSpec& fold), you could just call super in
your override.


 _______________________________________________
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: virtual method hidden
      • From: "Sean McBride" <email@hidden>
    • Re: virtual method hidden
      • From: "Andy O'Meara" <email@hidden>
  • Prev by Date: std C++ linking errors with gcc 4 (was Re: XCode 2.1 w/gcc 4.0 link error)
  • Next by Date: Re: Cannot link project checkedout from an SVN repository
  • Previous by thread: RE: virtual method hidden
  • Next by thread: Re: virtual method hidden
  • Index(es):
    • Date
    • Thread