There are two classes, the second class inherits the first. There are virtual functions in the base class and no virtual functions in the heir. What will be in the table of virtual functions of a class of the successor, is it empty or not created at all?

class base { private: int m_d; public: virtual void foo(); virtual void bar(); }; class derived : public base { int m_b; void baz(); }; 
  • 3
    most likely in the second class there will be a link to the table of virtual functions of the ancestor. But the compiler is not obliged to do code through a table of virtual functions. It's just the easiest way to implement inheritance. To be honest, the compiler can even throw out the table of virtual functions, if it can accurately calculate by the code which function will be called and when it will be called. - KoVadim
  • About an hour ago I was interviewed by telephone, to this question I answered that the table of virtual functions of the class of the heir would be empty, is this a very rude and inaccurate answer? - արդան Գրիգորյան
  • one
    Empty it can not be, as then call Wirth. functions? - fogbit
  • one
    Mandatory reference: phpcompiler.org/articles/virtualinheritance.html Reread before the arrival of satori. - VladD
  • five
    @Vardan: the correct answer - the virtual method table is an implementation detail in some compilers and is not guaranteed by the standard. - VladD

1 answer 1

In the derived table there will be pointers to base::foo() and base::bar()