class A
{
public:
void fun1(){}
virtualvoid fun2(){}
virtualvoid fun3(){}
};
class B: public A
{
public:
void fun4(){}
void fun2(){}
virtual fun5(){}
};
Virtual Function Table for class A have entries for below functions:
fun2
fun3
Virtual Function Table for class B have entries for below functions:
fun2
fun5
Please correct me and let me know if the entries are correct in Virtual function table for both classes A and B.
For class B, the virtual table contains all of the virtual functions for A plus the new one(s) for B.
B would have entries in it's vtable for fun2, fun3 and fun5
It is merely that the entry for fun3 points to the version in A because B didn't provide one.
To continue, if class C were derived from B, and if B provided a fun3 but nothing else, the vtable for C would contain entries for fun2, fun3 and fun5, but where fun3 points to C's version.
[ Edit: Niccolo is correct because fun4 is not declared as virtual ]
A small mis-statement in Noccolo's answer: B's vtable has entries for fun2, fun3, fun4, and fun5.
Thanks Niccolo and dhayden for quick reply.
Initially, I was doubtful about the entry of fun3 in B's virtual table and that's why I posted this query here.
I agreed with Niccolo that B's virtual table have entries - fun2, fun3 and fun5.
@dhayden,
I did not get about entry of fun4, could you please explain us.