B
Bangalore
Hi,
I am not understanding the problem in the below program,
#include <iostrema.h>
class Base
{
public:
virtual void display()
{
cout <<"Base \n";
}
};
class Derivedrivate Base
{
public:
void display()
{
cout <<"Derived \n";
}
};
int man()
{
Base *ptr=new Derived;
ptr->display();
return 0;
}
If I compile it, if flashes error "cannot convert Derived * to
Base*"
Can anybody clarify , why we get this error, that is only with
private
inheritance.
Thanks,
Bangalore
I am not understanding the problem in the below program,
#include <iostrema.h>
class Base
{
public:
virtual void display()
{
cout <<"Base \n";
}
};
class Derivedrivate Base
{
public:
void display()
{
cout <<"Derived \n";
}
};
int man()
{
Base *ptr=new Derived;
ptr->display();
return 0;
}
If I compile it, if flashes error "cannot convert Derived * to
Base*"
Can anybody clarify , why we get this error, that is only with
private
inheritance.
Thanks,
Bangalore