This is a well known technique for me but just recently I heard it was called as 'overriding virtualization'.
That's why I decided to expose how calling method from the explicitly mentioned class can override virtualization in classes.
Consider you have
class A
{
virtual void m();
};
class B : public A
{
virtual void m();
};
When you create instance of class B, you will call B::m in all cases:
A *a = new B;
a->m();/// B::m here
So, if you want to call
m from A? Easy:
A *a = new B;
a->A::m();/// A::m here
In the example above I've overridden the virtual call.
No comments:
Post a Comment