小编ban*_*dai的帖子

C++继承 - 难以访问的基础?

我似乎无法使用基类作为函数参数,我是否搞砸了我的继承?

我的主要内容如下:

int some_ftn(Foo *f) { /* some code */ };
Bar b;
some_ftn(&b);
Run Code Online (Sandbox Code Playgroud)

并且以这种方式继承自Foo的类Bar:

class Bar : Foo
{
public:
    Bar();
    //snip

private:
    //snip
};
Run Code Online (Sandbox Code Playgroud)

这应该不起作用吗?我似乎无法在我的主要功能中进行该调用

c++ inheritance

137
推荐指数
2
解决办法
9万
查看次数

标签 统计

c++ ×1

inheritance ×1