假设我有课程,Foo并且Bar设置如下:
class Foo
{
public:
int x;
virtual void printStuff()
{
std::cout << x << std::endl;
}
};
class Bar : public Foo
{
public:
int y;
void printStuff()
{
// I would like to call Foo.printStuff() here...
std::cout << y << std::endl;
}
};
如代码中所注释的那样,我希望能够调用我要重写的基类的函数。在Java中有super.funcname()语法。这在C ++中可能吗?
呼唤远方
MYYA
哔哔one
相关分类