派生的类为什么不能访问自己的私有成员啊
程序代码:
#include <iostream.h> enum br {aa,bb,cc,dd,ee,ff,gg}; class mammal { public: mammal(); mammal(int i); ~mammal(); int getage(){return age;} void setage(int j){age = j;} int getwidth(){return width;} void setwidth(int w){width=w;} protected: int age; int width; }; class dog:public mammal { dog(); dog(int itsage); dog(int itsage,int itswidth); dog(int itsage,br hh); dog(int itsage,int itswidth ,br hh); ~dog(); br getbr(){return mm;} void setbr(br mmm){mm=mmm;} private: br mm; }; mammal::mammal(): age(1), width(50) { cout << "初始化\n"; } mammal::mammal(int i): age(i), width(5) { cout << "初始化年龄\n"; } mammal::~mammal() { } dog::dog(): mammal(), mm(bb) { } dog::dog(int itsage): mammal(itsage), mm(bb) { } dog::dog(int itsage,int itswidth): mammal(itsage), mm(bb) { width=itswidth; } dog::dog(int itsage,int itswidth ,br hh): mammal(itsage), mm(hh) { width=itswidth; } dog::dog(int itsage,br hh): mammal(itsage), mm(hh) { } dog::~dog() { } int main() { mammal p(50); cout << p.getage() << "\n" << p.getwidth()<< endl; p.setage(03); p.setwidth(06); cout << p.getage() << "\n" << p.getwidth()<< endl; dog p1; cout << p1.getbr() << endl; return 0; }一直提示dog不能访问私有成员