我似乎无法使用基类作为函数参数,我是否搞砸了我的继承?
我的主要内容如下:
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)
这应该不起作用吗?我似乎无法在我的主要功能中进行该调用