Need some information about function hiding
Here is some piece of code -
class A
{
public:
explicit A(){printf("constructing A\n");};
};
class base
{
public:
virtual void foo(int i) {printf("inside base\n");};
};
class derived : public base
{
public:
virtual void foo(A &i) {printf("inside derived\n");};
};
main()
{
base *ptr = new derived();
ptr->foo(1);
}
"test.cpp" 21 lines, 607 characters
CC test.cpp
"test.cpp", line 14: Warning: derived::foo hides the virtual function
base::foo(int).
1 Warning(s) detected.
a.out
inside base
I understand that when I replace the argument type for a function in
derived type, original defn gets hidden.
Only thing I find really interesting is why in case we have types
which can not be converted by promoting (like I can promote int to
float) definitions are still hidden.
Also, with default rules I am having hard time explaining execution
which is above on sun solaris CC.
Can you please help.
Thanks & Regards,
Abhijeet
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]