-3

Suppose I have two classes class A and class B, class B is derived from class A public. Here class A have virtual emp(),and class B have emp(), In this case how can I call base class virtual function?

Code_Ninja
  • 1,729
  • 1
  • 14
  • 38
krishna
  • 5
  • 2
  • Possible duplicate of [Call base class method from derived class object](https://stackoverflow.com/questions/15853031/call-base-class-method-from-derived-class-object) – Bowdzone Jun 11 '18 at 06:08

1 Answers1

7

You can invoke A::emp() directly

B* obj = new B();
b->A::emp();

Or within a method of A or B.

void B::SomeOtherMethod()
{
     A::emp(); // same as this->A::emp();
}
selbie
  • 100,020
  • 15
  • 103
  • 173
  • @Krishna - Welcome to Stack Overflow. If the answer works for you, don't forget to "accept" it. – selbie Jun 11 '18 at 03:19