C++ overridden function not called

后端 未结 3 491
攒了一身酷
攒了一身酷 2021-01-28 12:01

I am running into an issue where an overloaded function is not called, and the base function is called instead. I suspect this is related to how things are split between the pr

3条回答
  •  心在旅途
    2021-01-28 12:29

    You should declare print() as virtual to calling obj2::print() for obj2 objects.

    virtual void print();
    

提交回复
热议问题