C++ method only visible when object cast to base class?

后端 未结 7 2430
栀梦
栀梦 2020-11-29 10:27

It must be something specific in my code, which I can\'t post. But maybe someone can suggest possible causes.

Basically I have:

class CParent
{
 publ         


        
7条回答
  •  暖寄归人
    2020-11-29 10:50

    I understand that this behavior is to give you flexibility to override the behavior of base class method in your derived class.

    Lets assume that you have a function foo(int) in base class and you want to change the behavior of this function in your derived class. Now if the base class method is not hidden by your derived class method (which has same prototype as that of base class's method), it will introduce ambiguity in overload resolution.

提交回复
热议问题