public and protected member in private inherit# Programming - 葵花宝典
i*p
1 楼
They are accessible in the 1st inheritence, but not in 2nd (see error in the
following code). What reason made C++ designed this way?
class Base
{
protected:
int pro_stat;
public:
int pub_stat;
};
class Default_Der1 : Base
{
int Der1GetProStat() { return pro_stat; } int Der1GetPubStat() { return pub_stat; } };
class Default_Der2 : Default_Der1
{
int Der2GetProStat() { return pro_stat; } int Der2GetPubStat() { return pub_stat; } };
following code). What reason made C++ designed this way?
class Base
{
protected:
int pro_stat;
public:
int pub_stat;
};
class Default_Der1 : Base
{
int Der1GetProStat() { return pro_stat; } int Der1GetPubStat() { return pub_stat; } };
class Default_Der2 : Default_Der1
{
int Der2GetProStat() { return pro_stat; } int Der2GetPubStat() { return pub_stat; } };