继承的问题
#include<iostream>using namespace std;
class box
{
protected :
int chang;
int kuan;
int gao;
};
class box1:public box
{
public:
void set1()
{
cin>>chang>>kuan>>gao>>time;
}
void show1()
{
cout<<chang<<" "<<kuan<<" "<<gao<<" "<<time<<endl;
}
private:
int time;
};
void main()
{
box1 b1;
b1.set1();
b1.show1();
cout<<b1.chang<<endl; // 我采用的是公有继承的方式,基类的protected数据在派生类里已经成了public成员,可为什么不能引用呢????
}