可能性の重複:
How to force child same virtual function call its parent virtual function firstを実行し、基本クラスの機能と、その後継承されたクラスの機能
EDITの人々は完全にポイントを逃している:クラスの多くが継承している場合、私はあるになっていた何ベース、私は毎晩Base::myFunction()
に電話する必要はありません!
私はどの単語この質問をする本当にわからないんだけど、私はそれがコード(これは実際に私はすぐにそれを書いた、コンパイルされない場合があります)から明らかに願っています:
class Base
{
bool flag = false;
void myFunction()
{
flag = true;
// here run the inherited class's myFunction()
}
};
class A : public Base
{
void myFunction()
{
// do some clever stuff without having to set the flags here.
}
};
int main()
{
A myClass;
myClass.myFunction(); // set the flags and then run the clever stuff
std::cout << myClass.flag << endl; // should print true
return 0;
}
あなたは 'virtual void myFunction'を意味しましたか? – Thomas
説明するには[C++ faq](http://www.parashift.com/c++-faq-lite/virtual-functions.html#faq-20.5)を参照してください – EdChum