#include<iostream>
#include<stdio.h>
using namespace std;
class Test;
class Base {
protected:
int mltem;
private:
int mCount;
friend class Test;
};
class Sub:public Base {
public:
void Test(const Sub& sub,const Base& base)
{
int i=mltem; //(A)
i = sub.mltem; //(B)
i = base.mltem; //(C)
}
};
class Test
{
public:
int Count(const Base& base)
{
return base.mCount; // (D)
}
};
int main() {
// your code goes here
return 0;
}
【解析】
答案:C
1.公有继承:
派生类可以访问基类的非私有成员;
派生类对象可以访问基类的公有成员;
2.私有继承与保护继承:
派生类可以访问基类的非私有有成员;
派生类对象不可以访问基类的所有成员;