Error while calling a virtual function
<p>I have an error while calling a virtual function that is defined in Derived class but not present in Base class? Why this error when I have pointer pointing to derived class? </p>

<pre><code>#include&lt;iostream.h&gt;

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

class B : public A
{
public:

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

int main()
{
A *obj1=new B;
obj1-&gt;fun();
obj1-&gt;func();
}
</code></pre>
