假设我有如下设置的类 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++中可行吗?