Topic: Virtual function overloading and hiding
Author: tkacik@adtaz.sps.mot.com (Tom Tkacik)
Date: Wed, 6 Jul 1994 19:46:33 GMT Raw View
Moving from a cfront 2.1 to a cfront 3.0 based C++ compiler,
I noticed what must either be a bug in my code (I don't think so),
a bug in cfront 3.0, or a change in the C++ language definition.
I am hoping someone can tell me which it is.
The following code compiles without warning or error when
using cfront 2.1. Cfront 3.0 gives the following warning.
"test.c", line 12: warning: PopupMenu::Popup() hides virtual Menu::Popup()
I thought that two virtual functions with the same name but
different arguments were different, and that one should not
hide the other. In the following example, that is what
seems to have happened.
Is the compiler supposed to give the above warning? If so, why?
Has the language changed recently in this respect?
Thanks
Tom Tkacik
tkacik@adtaz.sps.mot.com
------------ test.c ---------
class A;
class B;
class Base {
public:
virtual void Popup(A*);
virtual void Popup(B*);
};
class Derived : public Base {
public:
virtual void Popup(A*); //<------- line 12
};
Author: wikman@king.trshp.trs.ntc.nokia.com (Johan Wikman)
Date: 07 Jul 1994 06:42:34 GMT Raw View
>>>>> "Tom" == Tom Tkacik <tkacik@adtaz.sps.mot.com> writes:
Tom> "test.c", line 12: warning: PopupMenu::Popup() hides
Tom> virtual Menu::Popup()
Tom> Is the compiler supposed to give the above warning? If so, why?
Tom> Has the language changed recently in this respect?
Yes it is. See ARM 13.1.
Johan
--
--
Johan Wikman
wikman@ntc.nokia.com; C=FI,A=Elisa,P=Nokia Telecom,S=Wikman,Gi=Johan
TL4E - P.P. Box 12, SF-02611 Espoo 61, Finland