以下是引用TYGL在2006-5-28 19:48:00的发言:
class X
{ protected:int i,j;
public:
void get_ij(){cout<<"enter two numbers:";cin>>i>>j;}//;
void put_ij(){cout<<""<<j<<'\n';}//;
};
class Y:private X //-------------------因为这里是私有继承
{ int k;
public:
int get_k(){return k;}//;
};
main()
{Y var1;
var1.get_ij(); //为什么书上说这行是错的?
var1.put_ij(); //为什么书上说这行是错的?
}
成员属性 继承方式 访问方式
publlic public public
public private 不能直接访问
public protected protected
protected public protected
protected protected protected
protected private 不能直接访问
private public private
private private 不能直接访问
private protected private
//不大记得了,应该是这样吧
[此贴子已经被作者于2006-5-28 20:35:48编辑过]