C++ Virtual function being hidden

后端 未结 6 1366
粉色の甜心
粉色の甜心 2020-12-05 10:56

I\'m having a problem with C++ inheritance.

I have a class hierarchy:

class A {
public:
   virtual void onFoo() {}
   virtual void onFoo(int i) {}
};         


        
6条回答
  •  生来不讨喜
    2020-12-05 11:28

    You forgot public: modifier before methods in both class A and B. Therefore method onFoo is private and thus not visible anywhere outside these classes.

提交回复
热议问题