class Base
{
public:
virtual void fn(){cout<<"fn base\n";}
virtual void myfn(){cout<<"myfn base\n";}
};
class Derived : private Base
{
private:
void fn(){cout<<"der\n";}
void myfn(){cout<<"myfn Derived\n";}
};
int _tmain(int argc, _TCHAR* argv[]){
Derived d;
Base *p = &d; //Error: conversion from derived * to base * exists but is inaccessible
p->fn();
p->myfn();
}
in the code above, I get an error as mentioned above. Why ?
If i change the pointer initialization to
Base *p = (Base *)&d;
it works fine.
Please explain ... Thnx