Virtual Function

in a class hierarchy,can a derived class, declare a virtual function??
i.e.
class A {}
class B: public A {virtual void foo(){}}
class c: public B{} etc...

in this hierarchy can B declare a virtual function ; in that case what will be scenario of V table???

Comments

  • : in a class hierarchy,can a derived class, declare a virtual
    : function??
    : i.e.
    : class A {}
    : class B: public A {virtual void foo(){}}
    : class c: public B{} etc...
    :
    : in this hierarchy can B declare a virtual function ; in that case
    : what will be scenario of V table???

    Sure it can.
    Class A doesn't introduce new entries to its V-table. Class B inherits A's V-table and adds foo(). Class C inherits from B again without any changes. Only when C overrides B.foo() then it will change its V-table.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion