I had been requested this crazy question. I had been from my wits.

Can a technique in base class that is declared as virtual be known as while using base class pointer that is pointing to some derived class object?

Is possible?

If you are attempting to invoke an online method in the base class pointer, yes.

That's polymorphism.

If you are asking, having a base class pointer to some derived class, are you able to invoke basics class method that's overriden through the derived class? Yes that's also possible by clearly scoping the bottom class title:



class A            

class B : public A 

A *b = new B()

b->A::foo ()

You mean something similar to this. (Where pBase is of type pointer-to-base however the pointed-to object is really of type Derived which comes from Base.)


Yes, it is possible.

Yes -- you need to specify the entire title though:

#include <iostream>

struct base 

struct derived : base 

int primary() remove b


Basically comprehend the question properly, you've

class B

class D: public B

B* b = new D

And now you ask ,, are you able to call B::foo(). The reply is yes, using


class B

class D: public B

B* b = new D

Try calling


to invoke base class foo function

No. Not inside a clean way. But yes. You need to do some pointer manipulation, get yourself a pointer towards the vtable making a call. but that's not quite a pointer to base class, however, many wise pointer manipulation. Another approach is applying scope resolution operator on base class.