( 33 )下面程序中对一维坐标点类 Point 进行运算符重载
#include
using namespace std;
class point {
public:
point ( int vaI ) {x=val;}
point & operator++ () {x++;retum*this;}
print operator++ ( int ) {point ld=*this,++ ( *this ) ;retum old;}
int GetX () const {retum x;}
private:
int x;
};
int main ()
{
point a ( 10 ) ;
cout<< ( ++a ) .GetX () ;
cout<<A++.GETX () ;
retum () ;
}
编译和运行情况是
A )运行时输出 1011
B )运行时输出 1111
C )运行时输出 1112
D )编译有错
第1题:
若有语句int *point, a=4; point=&a; 下面均代表地址的一组选项是
A.point, *&a
B.&*a, &a, *point
C.*&point, *point, &a
D.&a, &*point , point
第2题:
Point为一个类,下面的友元运算符重载函数原型中,正确的是()
A.friend float operator + (float);
B.friend Point operator + (float x, float y);
C.friend Point operator + (float, float);
D.friend Point & operator + (Point, float);
第3题:
若有语句 int *point, a = 4; point = &a; 下面均代表地址的一组选项是()。
A.point,*&a
B.&*a,&a, *point
C.*&point, *point, &a
D.&a, & *point,point
第4题:
下列哪个关于加号“+”运算符重载的成员函数声明格式是正确的。
A.POINT operator+(POINT b);
B.POINT +(POINT b);
C.POINT operator+();
D.POINT +(int);
E.POINT operator +(POINT a, POINT b);
第5题:
若有语句 int *point, a = 4; point = &a; 下面均代表地址的一组选项是()
A.point,*&a
B.&*a,&a, *point
C.*&point, *point, &a
D.&a, & *point,point