If I have a base class:
struct Base { void foo() { bar(); } virtual void bar() { } };
And the derived class:
struct Derived : public Base { void bar() { cerr << "Derived here\n"; } };
It happens that when writing this code:
Derived d; d.foo();
I will see the print "Produced here" - as Derived::bar was called. But I did not call through the pointer to the base, but polymorphism worked here. What for? Is this because the call to bar in Base::foo implicitly actually equal to this->bar() and is the bar in the vtable of the class?
source share