有如下程序: #include using namespace std; class Point{ public: Point(int xx=0,int yy=0):x(xx),

admin2019-05-22  23

问题 有如下程序:
       #include
       using namespace std;
       class Point{
       public:
           Point(int xx=0,int yy=0):x(xx),y(yy) { }
           void SetXY(int xx,int yy) { x=xx; y=yy; }
       protected:
           int x,y;
       };
       class Circle:Point{
       public:
           Circle(int r):radius(r) { }
           void Set(int r,int x,int y) { radius=r; SetXY(x,y); }  //①
           void Print() const { cout<       private:
           int radius;
       };
       int main(){
           Circle c1(5);
           c1.SetXY(10,1,2);                                      //③         
           c1.Print();                                            //④
           return 0;
       }
在标有号码的语句行中存在语法错误的是

选项 A、①
B、②
C、③
D、④

答案C

解析 C选项中SetXY为基类的成员函数,派生类也继承下来,但是SetXY的参数为两个,而③调用时是3个参数,所以错误。
转载请注明原文地址:https://kaotiyun.com/show/MI8p777K
0

最新回复(0)