Hi,

I've defined an abstract class IBase with a single method

virtual bool foo(){ printf(" IBase \n"); }


I've also defined a derived class TestDerived:IBase that overrides this method

bool foo(){ printf(" TestDerived \n");}


Finally I've a static lib with a function to use a IBase class

bool doSomething(IBase * foo);

implemented inside the library :

bool doSomething(IBase * foo){ foo->foo(); }

And this is the main program :
#include "mystaticlib.h"

int main(){
IBase * ptr = new TestDerived();
ptr->foo();
doSomething(ptr);
}
I was especting an output like :

TestDerived
TestDerived


But the output is

TestDerived
IBase

Why inside the lib, the ptr is accessing to the method of the base?


Thanks in advance.