Dynamic Object Not Creating for Privately Inherited Class.
- by mahesh
Hi,
What is the reason for the following code that does not let me to create object.
class base
{
public:
void foo()
{ cout << "base::foo()"; }
};
class derived : private base
{
public:
void foo()
{ cout << "deived::foo()"; }
};
void main()
{
base *d = new derived();
d->foo();
}
It Gives me error :
" 'type cast' : conversion from
'derived *' to 'base *' exists, but is
inaccessible"
Thanks in advance :)