Yep, it all has to do with virtual methods. Since your vtable points to B::yay(), you get a "1" when you call valp->yay(). This is just the nature of polymorphism.

If you want to call A's yay(),...