有以下类定义: class Point { public: Point(int x=0,int y=0){_x=x; _y=y;} void Move(int x Off, int y Off) {_x+=x Off

admin2010-03-29  25

问题 有以下类定义:    class Point {    public:         Point(int x=0,int y=0){_x=x; _y=y;}    void Move(int x Off, int y Off)    {_x+=x Off; _y+=y Off; }    void Print() const    {         cout <<’(’ << _x << ’,’ << _y << ’)’<< end 1;}    private:         int _x,_y;    }下列语句中会发生编译错误的是______。

选项 A、Point pt; pr. Print();
B、const Point pt; pt. Print();
C、Point pt; pt. Move(1,2);
D、const Point pt; pt. Move(1,2);

答案8

解析 const 修饰符改变值出错。
转载请注明原文地址:https://kaotiyun.com/show/tIjp777K
0

最新回复(0)