operator

在某类的公共部分有声明string operator++( );和string operator++(int);则说明

A:string operator++( );是前置自增运算符声明 B:string( )perator++( );是后置自增运算符声明 C:string operator++(int);是前置自增运算符声明 D:两条语句无区别

已知类MyClas有一个只需要一个double型参数的构造函数,其将运算符“+”重载为友元函数。要使语句序列 MyClas x(1.2),y(2.3),z(0);z=x+y; 能够正常运行,运算符函数 operator+应在类中声明为( )。

A:friend MyClas operator+(int,MyClas&); B:friend MyClas operator+(MyClas,MyClas); C:friend MyClas operator+(MyClas,MyClas&); D:friend MyClas operator+(MyClas&,MyClas);

在某类的公共部分有声明string operator++( );和string operator++(int);则说明

A:string operator++();是前置自增运算符声明 B:string operator++();是后置自增运算符声明 C:string operator++(int); 是前置自增运算符声明 D:两条语句无区别

在某类的公共部分有声明string operator++( );和string operator++(int);则说明

A:string operator++();是前置自增运算符声明 B:string operator++();是后置自增运算符声明 C:string operator++(in; 是前置自增运算符声明 D:两条语句无区别

已知类MyClas有一个只需要一个double型参数的构造函数,其将运算符“+”重载为友元函数。要使语句序列 MyClas x(1.2),y(2.3),z(0);z=x+y; 能够正常运行,运算符函数 operator+应在类中声明为( )。

A:friend MyClas operator+(int,MyClas&); B:friend MyClas operator+(MyClas,MyCla; C:friend MyClas operator+(MyClas,MyClas&); D:friend MyClas operator+(MyClas&,MyCla;

下面是“二维向量” vector2D 的定义,其中作为成员函数重载的运算符“+”的功能是将两向量的分量x和y对应相加,然后返回作为相加结果的新对象。那么应该在横线上填入的语句是( )。 class vector2D { private: double x; //x分量 double y; //y分量 public: vector2D(double x0=0,double y0=0) :x(x0),y(y0) {} void show(cout<<’ (’<<’, ’<<y<<’) ’;} _________________________; }; vector2D :: operator + (vector2D a) { return vector20(x+a.x,y+a.y); }

A:vector2D operator + (vector2D B:vector2D operator + (vector2D & C:void operator + (vector2D) D:int operator + (vector2D

在某类的公共部分有声明string operator++( );和string operator++(int);则说明

A:string operator++( );是前置自增运算符声明 B:string( )perator++( );是后置自增运算符声明 C:string operator++(in;是前置自增运算符声明 D:两条语句无区别

微信扫码获取答案解析
下载APP查看答案解析