mardi 12 juillet 2016

virtual function call from base class


Say we have: Class Base { virtual void f(){g();}; virtual void g(){//Do some Base related code;} }; Class Derived : public Base { virtual void f(){Base::f();}; virtual void g(){//Do some Derived related code}; }; int main() { Base *pBase = new Derived; pBase->f(); return 0; } Which g() will be called from Base::f()? Base::g() or Derived::g()? Thanks...

Aucun commentaire:

Enregistrer un commentaire