Apart from the invalid syntax (B->test();
where it should be b->test();
), the second one will also return 10.
If instead you would have written:
A* a = new B();
a->test();
It would have returned 0 or 10 depending on whether A::test is virtual.