有如下程序:
#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.
第1题:
有如下程序: #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,10
B.20,20
C.10,20
D.30,30
第2题:
有以下程序: #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; }
A.314
B.157
C.78.5
D.153.86
第3题:
第4题:
有如下程序: #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,10
B.20,20
C.10,20
D.30,30
第5题:
若有以下程序: #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,12
B.5,5
C.12,5
D.5,12