Possible Duplicate:
How to force child same virtual function call its parent virtual function first
EDIT People are completely missing the point: What I was getting at is if alot of classes inherit Base, I don't want to have to call Base::myFunction()
for every single one!
I'm not really sure how to word this question, but I hope it's apparent from the code (this may not actually compile, I wrote it quickly):
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;
}