If a private virtual function is overridden as a public function in the derived class, what are the problems?

前端 未结 3 1542
醉梦人生
醉梦人生 2020-12-03 16:17
using namespace std;
#include 
#include 

class One{
    private:
        virtual void func(){
            cout<<\"bark!\"<<         


        
3条回答
  •  隐瞒了意图╮
    2020-12-03 16:55

    A subclass can't ease inheritance restriction, even though func is virtual, it is still the inheritance restrictions remain.

    please see this answer for compliated view of inheritance restrictions :

    Difference between private, public, and protected inheritance

提交回复
热议问题