Under the right compiler the following code:
class Base
{
public:
virtual void Method(int){}
};
class Derived: public Base
{
public:
virtual void Method(float){}
};
will produce a warning such as:
'Derived::Metho d(float)' hides virtual function 'Base::Method(i nt)'
This warning can be eliminated by adding the statement:
using Base::Method;
to the derived class.
This issue with methods being hidden does not exist in other languages such as Java.
What is the reason that derived methods can potentially hide base methods in C++?
class Base
{
public:
virtual void Method(int){}
};
class Derived: public Base
{
public:
virtual void Method(float){}
};
will produce a warning such as:
'Derived::Metho d(float)' hides virtual function 'Base::Method(i nt)'
This warning can be eliminated by adding the statement:
using Base::Method;
to the derived class.
This issue with methods being hidden does not exist in other languages such as Java.
What is the reason that derived methods can potentially hide base methods in C++?
Comment