I am a beginner in c++. I understand that, virtual function can be used to resolve the conflict. Something like this,
in the given example, if virtual is not used, the parent class function is called.
but , why some one wants to declare a pointer of parent class type object and define it for a child class object.
A *obj1; //A is the base class
obj1=new(B) // B inherits A
what is the use? any good example?..
I will go for
Then no need to worry about virtual.
using namespace std;
virtual void disp();
class B : public A
obj1 = new(B);