In this example,a->f() will actually call void A::f(), because it's early (or statically) bound, and so the program at runtime thinks it's just a pointer to an A type variable, whereas a->g() will actually call void B::g(), because the compiler, seeing g() is virtual, injects code to look up the address of the correct function to call at runtime. More @Wikipedia
Hover over any link to get a description of the article. Please note that search keywords are sometimes hidden within the full article and don't appear in the description or title.