子类中调用父类的同名函数
class testFather
{
public:
virtual void foo(){ cout<<"testFather::foo()"<<endl;}
};
class testSon::public testFather
{
public:
void foo()
{
cout<<"testSon::foo()"<<endl;
testFather::foo();
}
};
如上面例子,子类改写了父类的foo()函数,但是又需要父类的foo()函数,用上面的方式调用有问题吗?
我主要想知道会不会造成什么不好的影响