标签:类继承 icp com 原来 ima 访问 cti 方式 private
class Base{
public:
void pub_mem();
protected:
int prot_mem;
private:
char pri_mem;
};
class Pub_derv : public Base{
int f(){
pub_mem();
return prot_mem;
}
//char g(){return pri_mem;}//error
};
class Pri_derv : private Base{
int f(){
pub_mem();
return prot_mem;
}
};
class Base{
public:
void pub_mem();
protected:
int prot_mem;
private:
char pri_mem;
};
class Pub_derv : public Base{
int f(){
pub_mem();
return prot_mem;
}
//char g(){return pri_mem;}//error
};
class Pri_derv : private Base{
int f(){
pub_mem();
return prot_mem;
}
};
class Pub_Pub_derv : public Pub_derv{
int f(){
pub_mem();
return prot_mem;
}
//char g(){return pri_mem;}//error
};
class Pri_Pri_derv : private Pri_derv{
int f(){
pub_mem();//error
return prot_mem;//error
}
};
c/c++ 继承与多态 继承中的public, protected, private
标签:类继承 icp com 原来 ima 访问 cti 方式 private
原文地址:https://www.cnblogs.com/xiaoshiwang/p/10199447.html