有如下程序: #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
第1题:
第2题:
第3题:
请将如下程序补充完整,使得输出结果为:bbaa。
include<iostream>
using naluespace std;
class A{
public:
______{eout<<"aa";}
};
class B:public A{
public:
~B( ){eont<<"bb";}
};
int ulain( ){
B*P=new B;
delete P;
return 0;
}
第4题:
有以下程序: #include<iostream> #include<math> using namespace std; class point { private: double x; double y; public: point(double a,double B) { x=a; y=b; } friend double distance (point a,point B) ;
A.1
B.5
C.4
D.6
第5题:
下列程序的执行结果为【 】。
include <iostream. h>
class Point
{
public:
Point(double i, double j) { x=i; y=j;}
double Area() const { return 0.0;}
private:
double x, y;
};
class Rectangle: public Point
{
public:
Rectangle(double i, double j, double k, double 1)
double Area() const {return w * h;}
private:
double w, h;
};
Rectangle: :Rectangle(double i, double j, double k. double 1): Point(i,j).
{
w=k, h=1
}
void fun(Point &s)
{
cout<<s. Area()<<end1;
}
void main( )
{
Rectangle rec(3.0, 5.2, 15.0. 25.0);
fun(rec)
}
第6题:
有以下程序: #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)
第7题:
有如下程序:
#include<iostream>
using namespace std;
class Point{
int x, y;
public:
Point(int x1=0, int y1=0):x(x1), y(y1){}
int get(){return x+y;)
};
class Circle{
Point center;
int radius;
public:
Circle(int CX, int cy, int r):center(cx, cy), radius(r){}
int get(){return center. get()+radius;}
};
int main(){
circle c(3, 4, 5);
cout<<c. get()<<end1;
return ():
}
运行时的输出结果是( )。
A) 5
B) 7
C) 9
D) 12
A.
B.
C.
D.
第8题:
有如下程序:#include<iostream>using namespace std;class Point{public: static int number;public: Point(){number++;} ~Point(){number--;}};int Point::number=0;void main(){ Point*ptr; Point A,B; { Point*ptr_point=new Point[3]; ptr=pb_point; } Point C cout<<Point::number<<endl; delete[]ptr; }运行时输出的结果是
A.3
B.4
C.6
D.7
第9题:
( 29 )有如下程序:
#include
using namespace std;
class point {
public:
static int number;
public:
point () {number++;
~ point () {number-;}
};
imt point::number=0;
void main () {
point*ptr;
printA,B;
{
point*ptr_point=new point{3};
ptr=ptr_point;
}
pointC;
cout<<POINT::NUMBER<<ENDL;
delete[]ptr;
}
运行时输出的结果是
A ) 3
B ) 4
C ) 6
D ) 7