有如下类定义: class Point{ public: void SetX(int xx) { x=xx; } void SetY(int yy) { y=yy; }

admin2015-07-22  1.2K+

问题 有如下类定义:
       class Point{
       public:
           void SetX(int xx) { x=xx; }
           void SetY(int yy) { y=yy; }
       private:
           int x,y;
       };
       class Circle:public Point{
       public:
           int GetRadius() { return radius; }
       private:
           void SetRadius(int r) { radius=r; }
           int radius;
           friend void show();
       };
在派生类 Circle 中函数show()可访问的成员的个数为

选项 A、1
B、3
C、5
D、7

答案C

解析 本题考查派生类对基类成员的访问属性,派生类公用继承基类,基类的私有成员不可访问,派生类的友元函数可以访问本类的所以成员以及基类的公用成员,所以可以访问的成员为5个,其中基类2个,本类中3个,所以C选项正确。
转载请注明原文地址:https://kaotiyun.com/show/juNp777K
0

最新回复(0)