Error while calling a virtual function that is defined in Derived class but not present in Base clas

Posted by sandeep on Stack Overflow See other posts from Stack Overflow or by sandeep
Published on 2010-03-25T09:42:00Z Indexed on 2010/03/25 9:53 UTC
Read the original article Hit count: 145

Filed under:
#include<iostream.h>

class A{
public:
virtual void fun()
{cout<<"A::fun()";
}
};

class B : public A
{
public:

virtual void fun()
{cout<<"B::fun()";
}
virtual void func()
{cout<<"B::func";
}
};

int main()
{
A *obj1=new B;
obj1->fun();
obj1->func();
}

© Stack Overflow or respective owner

Related posts about c++