6π-2πx
6π-πx2
12π-2πx
36π-2πx
36π-πx2
第1题:
有如下类定义:
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、3
B、1
C、5
D、2
答案:A
解析:本题考查默认构造函数和带参数的构造函数,题目中定义一个对象a(2)以及对象数组b[3],共执行3次构造函数,对象指针不调用构造函数。
第2题:
使用VC6打开考生文什夹下的工程test1_3。此工程包含一个test1_3.cpp,其中定义了类circle和column,其中column类由circle类protected派生,但两个类的定义并不完整。请按要求完成下列操作,将程序补充完整。
(1)定义类circle的保护数据成员r和area,它们都是double型的数据。请在注释“//**1**”之后添加适当的语句。
(2)添加类circle的无参数的构造函数,使circle对象的r默认值为0,请在汁释“//**2**”之后添加适当的语句。
(3)添加派生类column构造函数的定义,传入的参数为double型的height和radius,并将具分别赋值给数擗成员h和基类的r,请在注释“//**3**”之后添加适当的语句。
(4)完成派生类column的成员函数print的定义,使其以格式“r=_area=_”先输出半径r和底面积area,再以格式“h=_vol=_”输出高h和体积vol的值,请在注释“//**4**”之后添加适当的语句。
输山结果如下:
r=1 area=3.1416
h=2 vo1=6.2832
注意:除在指定的位置添加语句外,请不要改动程序中的其他语句。
源程序文件test1_3.cpp清单如下:
include<iostream.h>
const double pi=3.1416;
class circle
{
protected:
//**1**
public:
//**2**
circle(double radius){ r=radius;}
void print()
{
area=r*r*pi;
cout<<"r="<<r<<" "<<"area="<<ared<<endl;
}
};
class column: protected circle
{
protected:
double h;
public:
//** 3 **
void print()
{
// ** 4 **
}
};
void main()
{
column col(1.0,2.0);
Col.print();
}
第3题:
根据程序中的注释将下列缺失部分补充完整。
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()(cout<<3.14159*radius*radius<<end1;)
};
第4题:
第5题:
第6题:
第7题:
public abstract class Shape { private int x; private int y; public abstract void draw(); public void setAnchor(int x, int y) { this.x = x; this.y = y; } } Which two classes use the Shape class correctly?()
第8题:
6π-2πx
6π-πx2
12π-2πx
36π-2πx
36π-πx2
第9题:
y=3x+2
y=2x+1
y=-x+5
y=-2
y=-6
第10题:
y -x
x-y
x +y
(x2 + y2)/(x + y)
(x2 + y2)/(x - y)
第11题:
3/2
2/3
4/9
1/4
9/4
第12题:
16%
20%
40%
80%
96%
第13题:
阅读以下说明和C++代码,填入(n)处。
[说明]
以下C++代码使用虚函数实现了同一基类shape派生出来的Class rectangle、Class triangle、Class circle实现了计算矩形、圆形面积的计算。仔细阅读以下代码,将(n)处语句补充完整。
[代码5-1]
include<iostream.h>
define PI 3.14159
class shape {//基类
protected:
(1);
public:
(2);
(3);
};
[代码5-2]
class rectangle: public shape {
public:
rectangle (int x2,int y2,int r2): (4) {};
double area ( ) {return x*y; };
};
class circle: public shape {
public:
circle (int x3,int y3,int r3):(5){};
double area ( ) {return r*r*PI; };
};
[代码5-3]
void main ( )
{
rectangle r (10,20,0);
circle c (0,0,30);
shape (6);
cout<<"长方形面积="<<s1->area ( ) <<endl;
cout<<"圆形面积="<<s2->area ( ) <<endl;
}
[运行结果]
长方形面积=200
圆形面积=2827.43
第14题:
有如下程序:
#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.
第15题:
第16题:
第17题:
第18题:
某圆形零件轮廓可由方程X2–12X+Y2+6Y+9=0描述,则圆的圆心坐标和半径R为()。
第19题:
3
9
16
36
49
第20题:
第21题:
2A
4A
8A
16A
32A
第22题:
4π
8π
12π
16π
64π
第23题:
5x + 2
3x + 2
2-x
2 -3x
2-5x
第24题:
-4
0
2/x
4/x
-x/4