Code:
class derived; //forward declaration
class base {
public :
base *getobject()
{
if(/*condition*/)
return new derived();
else
/* do nothing */
}
virtual void paint() {} =0;
};
class derived : public base
{
public:
derived(){ }
void paint()
{
cout<<"in derived";
}
};
int main()
{
base *b,j,*k;
b=&j;
k = b->getobject();
k->paint();
}
please tell me whats the cause of error
Comment