有以下类定义 class Point{ public: Point{int x = 0, int y=0) {_x = x; _y = y;} void Move int xoff, int yoff) {_x +=xoff;_y+=yoff;} void Print() const {cout<<'('<<_x<<','<<_y<<')' << end1;} private: int_x,_y; }; 下列语句中会发生编译错误的是A.Point pt;pt.Print();B.const Point pt;pt.Print();C.Point pt;pt.Move(1, 2);D.const Point pt;pt.Move(1, 2)
有以下类定义 class Point{ public: Point{int x = 0, int y=0) {_x = x; _y = y;} void Move int xoff, int yoff) {_x +=xoff;_y+=yoff;} void Print() const {cout<<'('<<_x<<','<<_y<<')' << end1;} private: int_x,_y; }; 下列语句中会发生编译错误的是
A.Point pt;pt.Print();
B.const Point pt;pt.Print();
C.Point pt;pt.Move(1, 2);
D.const Point pt;pt.Move(1, 2)
相关考题:
有如下类定义:class Point{int x_, y_;public:Point():x_(0), y_(0){}Point(int x, int y = 0):x_(x),y_(y){}};若执行语句Point a(2), b[3] , *c[4];则 Point 类的构造函数被调用的次数是A . 2 次B . 3 次C . 4 次D . 5 次
下列函数原型声明中错误的是A.void Fun(int x=O,int y=0);B.void Fun(int x,int y);C.void Fun(int x,int y=0);D.void Fun(int x=0,int y);
有以下类定义 classPoint{ public: Point(int x=0,int y=0){_x=x;_y=y;} void Move (int xOff,int yOff {_x +=xOff;_y+yOff} void Print() const {cout<<'('<<_x<<','<<_y<<')'<<endl;} private: int_x_y; }; 下列语句中会发生编译错误的是A.Pointpt;pt;Print();B.const Point pt;pt.Print();C.Pointpt;pt.Move(1,2);D.const Point pt;pt.Move(1,2);
有如下类定义:class Point{public:Point(int xx=0,int yy=0):x(xx),y(yy) { }private:int x,y;};class Circle:public Point{public:Circle(int r):radius(r) { }private:int radius;};派生类Circle中数据成员的个数是( )。A、3B、1C、5D、2
分析以下程序的执行结果【】。includeclass Sample{int x, y;public:Sample() {x=y=0; 分析以下程序的执行结果【 】。include<iostream.h>class Sample{int x, y;public:Sample() {x=y=0; }Sample(int a, int b) { x=a; y=b;}~Sample(){if(x==y)cout<<"x=y"<<end1;elsecout<<"x!=y" <<end1;}void disp(){cout<<"x="<<x<<",y="<<y<<end1;}};void main(){Sample s 1 (2,3);s1.disp();}
如下的类定义,括号里应填( )。 class Myclass { public: MyClass(int a =0,int b =0) { X=a; Y=b; void Change ( ) const { X- =10; Y+ =10; public: ( )int X,Y;A.staticB.constC.mutableD.可以不添内容
有以下程序: include using namespace std; class Point' { public: void SetPoint( 有以下程序: #include <iostream> using namespace std; class Point' { public: void SetPoint(int x,int y); void Move(int xOff,int yOff); int GetX() { return X; } int GetY() { return Y; } private: int X,Y; }; void Point::SetPoint(int x, int y) { X=x; Y=y; } void Point: :Move(int xOff, int yOff) X+=xOff; Y+=yOff; } int main () { Point p1; p1.SetPoint(1,2); p1.Move (5, 6); cout<<"Point1 is ("<<p1.GetX()<<','<<p1.GetY()<<")"<<end1; return 0; } 执行后的输出结果是( )。A.Point1 is (6,8)B.Point1 is (1,2)C.Point1 is (5,6)D.Point1 is (4,4)
下面是类MyClass的定义,对定义中各种语句描述正确的是( )。class MyClass { publiC: void MyClass(int a) //①{ x=a; ) int func(int a,int b) //②{ x=a; y=b; } int func(int a,int b,int c=0) //③{ x=a; y=b; z=c; } static void resetValue() //④{ x=0; } private: int X,y,Z; };A.语句①是类MyClass的构造函数定义B.语句②和语句③实现类成员函数的重载C.语句④实现对类成员变量x的清零操作D.语句①、②、③和④都不正确
有以下程序:includeusingnamespacestd;definePI3.14classPoint{private: intx,y;pub 有以下程序: #include <iostream> using namespace std; #define PI 3.14 class Point { private: int x,y; public: Point(int a,int b) { x=a; y=b; } int getx() { return x; } int gety() { return y; } }; class Circle : public Point { private: int r; public: Circle(int a,int b,int c):Point(a,b) { r=c; } int getr() { return r; } double area() { return PI*r*r; } }; int main() { Circle c1(5,7,10); cout<<cl.area()<<endl; return 0; } 程序执行后的输出结果是A.314B.157C.78.5D.153.86
下列程序的输出结果是includeclass Myclass{public : Myclass( int i=0,int j=0){x 下列程序的输出结果是 #include<iostream.h> class Myclass{ public : Myclass( int i=0,int j=0) {x=i; y=j; } void show( ){cout<<"x="<<x<<" "<"y="<<y<<endl;} void show( )const{cout<<"x="<A.x=4,y=3;x=7,y=8B.x=3,y=4;x=7,y=8C.x=7,y=8;x=4,y=3D.x=8,y=7;x=7,y=8
有如下类的定义。应在空格处填入的语句是 ( )。 class MyClass { ______________ int x, y; public: MyClass(int a=0,int b=0) { x=a; y=b; } static void change{) { x-=10; y-=10; };A.staticB.constC.mutableD.不需要填入内容
有以下程序: include using namespace std; voidt(intx,inty, intcp,intdp) {cp=x*x+y 有以下程序:include <iostream>using namespace std;void t(int x,int y, int cp,int dp){cp=x*x+y+y;dp=x*x-y*y;}int main(){int a=4,b=3,c=5,d=6;t(a,b,c,D) ;cout<<c<<","<<d<<end1;return 0;
有如下类的定义。那么空格处的语句是( )。 class MyClass { ____________int x,y; public: MyClass(int x1=0,int y1=0) { x=x1; y=y1; } static void change() { x+=10; y+=10; } };A.staticB.constC.privateD.不需要填入内容
有如下类定义:class Point{int x__, y__;public:Point(): x_(0), y_(0) {}Point(int x, int y =0): x_(x), y_(y) {}若执行语句Point a(2),b[3], *c[4];则Point 类的构造函数被调用的次数是( )。A.2次B.3次C.4次D.5次
有如下类的定义,下划线处的语句是( )。class MyClass{_______________ int x, y;Public:MyClass (int a=0,int b=0){x=a;y=b;}static void change(){y-=10;y-=10;}};A.staticB.constC.mutableD.不需要填入内容
有如下类的定义。空格处的语句是class MyClass{ ______ int x, y;public: MyClass(int a=0, int b=0) { x=a; y=b; } static void change() { x-=10; y-=10; }};A.staticB.constC.privateD.不需要填入内容
下列函数原型声明中错误的是( )。A.void fuc(int x=0,int y=0)B.void fnc(int x,int y)C.void fuc(int x,int y=0)D.void fuc(int x=0,int y)
有如下程序: include using namespace std; class point {int x,y; public:point( i 有如下程序: #include <iostream> using namespace std; class point { int x, y; public: point( int vx, int vy ) { x = vx; y = vy; } point ( ) { x = 0; y = 0; } point operator+( point pl ) { point p; int px = x + p1.x; int py = y + p1.y; return point( px, py ); } point operator-( point p1 ) { point p; int px = x - p1.x; int py = y - p1.y; return point( px, py ); } void print() { cout<<x<<", "<<y<<end1; } }; int main () { point pl ( 10, 10 ), p2 ( 20, 20 ); p1 = p1 + p2; p1.print (); return 0; } 执行后的输出结果是( )。A.10,10B.20,20C.10,20D.30,30
有如下程序:includeusing namespace std;class point{int x,y;public:point(int vx,i 有如下程序: #include<iostream> using namespace std; class point { int x,y; public: point(int vx,int vy) { x=vx; y=vy; } point() { x=0; y=0; } point operator+(point p1) { point p; int px=x+p1.x; int py=y+p1.y; return point(px,py); } point operator-(point p1) { point p; int px=x-p1.x; int py=y-p1.y; return point(px,py); } void print() { cout<<x<<","<<y<<end1; } }; int main() { point p1(10,10),p2(20,20); p1=p1+p2; p1.print(); retrun 0; } 执行后的输出结果是A.10,10B.20,20C.10,20D.30,30
有如下类的定义,横线处的语句是( )。 class TestClass { ______ int x,y; public: TestClass(int a=0,int b=0) { X=a: y=b; } static void change() { y-=10; y-=10; } };A.publicB. privateC.staticD.protected
有以下类定义: 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);
includeiostream.hclass A{private:int x,y;public:void f1(int i=0,int j=0){x=i;y=j;}void print(){coutx yendl;}void f1(int i=0){x=i,y=0;}};void main(){A a;a.f1(5);a.print();}
若有以下程序:include using namespace std;class point{private: int x, y;public: 若有以下程序: #include <iostream> using namespace std; class point { private: int x, y; public: point ( ) { x=0; y=0; } void setpoint(int x1,int y1) { x=x1; y=y1;A.12,12B.5,5C.12,5D.5,12
有以下程序:includeincludeusingnamespacestd;classDistance;classpoint{pub 有以下程序: #include <iostream> #include <cmath> using namespace std; class Distance; class point { public: friend class Distance; Point(int a,int B) { x=a; Y=b; } void Print() { cout<<"X= "<<X<<end1; cout<<"Y= "<<Y<<end1; } private: float X,Y; }; class Distance { public: float Dis(Point p,Point q); }; float Distance :: Dis(Point p,Point q) { float result; result=sqrt((p.X-q.X)*(p.X-q.X)+(p.Y-q.Y)*(p.Y-q.Y)); cout<<result<<end1; retUrn result; } int main() { Point p(10,10),q(10,30); Distance d; d.Dis(p,q); return 0; } 运行后的输出结果是( )。A.10B.30C.0D.20
根据程序中的注释将下列缺失部分补充完整。class Point{int x,y; //点的x和y坐标public:Point(int xx=0,int yy=0):x(xx),y(yy){}};class Circle{Point center;//圆心位置int radius; //半径public: //利用cx和cY分别初始化圆心的x和y坐标circle(int cx,int cy,int r): 【 】 ,radius(r){}void area()(cout3.14159*radius*radiusend1;)};
给定java代码如下所示,在A处新增下列()方法,是对cal方法的重载。public class Test { public void cal(int x, int y, int z) { } //A } A、public int cal(int x,int y,float z){return 0;}B、public int cal(int x,int y,int z){return 0;}C、public void cal(int x,int z){}D、public viod cal(int z,int y,int x){}
多选题给定java代码如下所示,在A处新增下列()方法,是对cal方法的重载。public class Test { public void cal(int x, int y, int z) { } //A }Apublic int cal(int x,int y,float z){return 0;}Bpublic int cal(int x,int y,int z){return 0;}Cpublic void cal(int x,int z){}Dpublic viod cal(int z,int y,int x){}