小编Rob*_*moo的帖子

受保护的函数调用c ++

Class Base() {
protected:
    void foo();
}
Class Derived : public Base {
    void bar();
}

void Derived::bar(){
    foo();    //this causes an error.
}
Run Code Online (Sandbox Code Playgroud)

我知道我可能错过了一些明显的东西,但我已经绕圈了一个小时.如何在派生类中调用受保护的函数?

c++ inheritance

-2
推荐指数
1
解决办法
979
查看次数

标签 统计

c++ ×1

inheritance ×1