0

#include <iostream> using namespace std; class A{ public: void f1(); }; class B : public A{ public: virtual void f1(); } int main() { A * obj = new B; obj.f1(); } Ques: can we write virtual before an overridden function from the base class?? if yes which f1() should it call base class f1() or derived class f1()???

Mine ans is coming as base class f1()... but since we are using virtual infront of f1() is should be late binding..where as here it is doing early binding...

24th Sep 2016, 10:52 AM
Amit
Amit - avatar
1 Réponse
0
No, we can not write virtual before an overridden function from the base class. More information are in the virtual functions and abstract classes lessons.
4th Nov 2016, 11:11 PM
Dani Tar
Dani Tar - avatar