I understand everything what is stated here, it describes how Child accesses Parent members. But, how about Parent Accessing Child? I just can't understand this. Why it is wrong? Could you please explain in terms of static binding rules during compile time? Here Student class itself becomes protected I guess, but why?
using namespace std;
class Person
{
public:
int b;
};
class Student : protected Person
{
public:
int c;
};
int main()
{
Student s;
Person *pPerson;
pPerson = &s;
return 0;
}
Aucun commentaire:
Enregistrer un commentaire