下面程序的输出结果是( )。 #include <iostream> using namespace std; class point { public: point(int px=10,int py=10){ x=px;y=py;} getpx( ) { return x;} getpy( ) { return y;} private: int x,y; }; void main(voiD) { point p,q(15,15); cout<<"p点的坐标是:"<<p. getpx( )<<" ,"; cout<<p. getpy( )<<endl; cout<<"q点的坐标是:"<<q. getpx( )<<" ,"; cout<<q. getpy( ); }
A.p点的坐标是:10,10 q点的坐标是:15,15
B.p点的坐标是:0,0 q点的坐标是:15,15
C.p点的坐标是:0,0 q点的坐标是:0,0
D.p点的坐标是:10,10 q点的坐标是:10,10
第1题:
下列程序的输出结果为:
bjectid=O
biectid=1
请将程序补充完整。
include<iostream>
using namespace std;
class Point
{
public:
Point(int xx=0,int yy=0){X=xx;Y=yy;countP++;}
~Point(){countP--;}
int GetX(){return X;}
int GetY(){return Y;}
static void GetC(){cout<<"Object id="<<countP<<endl;}
private:
int X,Y;
static int countP;
};
______//静态数据成员的初始化
int main()
{
Point::GetC();
Point A(4,5);
A.GetC();
return 0;
}
第2题:
下列程序的输出结果为
Object id=0
Obiect id=1
请将程序补充完整。
include<iostream>
using namespace std;
class Point
{
public:
Point(int xx=O,int yy=O){X=xx;Y=yy;countP++;}
~Point(){countp--;}
int GetX()(return X;)
int GetY(Xremm Y;)
static void GetC(){cout<<"Objcetid="<<countp<<endl;}
private:
int X,Y;
static int countP;
}:
【 】。 //静态数据成员的初始化
int main()
{
Point::GetC();
Point A(4,5);
A.GetC()
return 0;
}
第3题:
有如下程序: #inClude<iostream> using namespaCe std; Class Point{ publiC: statiC int number; publiC: Point( )t.number++;} ~Point( ){number--;} }; , int P0int::number=0; int main( ){ Point *ptr: Point A,B; Point*ptr_point=new Point[3]; ptr=ptr_point;’ } Point C; Cout<<Point:::number<<endl; delete[]ptr; return 0; } 执行这个程序的输出结果是( )。
A.3
B.4
C.6
D.7
第4题:
有以下程序: #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)
第5题:
下列程序的输出结果为
Object id=0
Object id=1
请将程序补充完整。
include <iostream>
using namespace std;
class Point
{
public:
Point(int xx=0,int yy=0) {X=xx;Y=yy;countP++;}
~Point(){countP--;}
int GetX(){return X;}
int GetY(){return Y;}
static Void GetC(){cout<<"Object id="<<countP<<endl;}
private:
int X,Y;
static int countP;
};
______ //静态数据成员的初始化
int main ()
{
Point::GetC();
Point A(4,5);
A.GetC();
return 0;
}
第6题:
下面程序的输出结果是( )。 #include <iostream> using namespace std; class A { public: A( ) {cout<<"A";} } class B { public: B() {coat<<"B" ;} } class C: public A { public: B b; C() {cout<<"C";} } void mian(){ C c; }
A.CBA
B.ABC
C.ACB
D.BCA