How to call Base class method through base class pointer pointing to derived class

后端 未结 3 1419
陌清茗
陌清茗 2020-12-18 20:22
class Base
{
  public:
    virtual void foo()
    {}
};

class Derived: public Base
{
  public:
    virtual void foo()
    {}
};

int main()
{
    Base *pBase = NULL         


        
3条回答
  •  借酒劲吻你
    2020-12-18 21:02

    Both responses above are correct...But be careful, if you need to do that, maybe you have a big problem about the conception or the design...

提交回复
热议问题