-
在编写C++程序时,一定要注意采用人们习惯使用的书写格式,否则会降低其可读性。
A . 正确
B . 错误
-
建造体育馆,要先设计图纸,然后再建造,这说明()。
A . 意识可以创造物质
B . 意识决定物质
C . 意识对物质有能动作用
D . 意识活动具有目的性、计划性
-
程序设计语言中引入"类"的概念是为了解决数据保护问题。C++语言将类的成员封装在类体之中,使之具有一定的存取规则,这些规则规定了存取类的成员的权利,其中,对于用private说明的成员,它()。
A . 既能被该类的成员函数访问,又能被外界直接访问
B . 只能被该类的成员函数访问,外界不能直接访问
C . 不能被该类的成员函数访问,只能被外界直接访问
D . 既不能被该类的成员函数访问,也不能被外界直接访问
-
在C语言程序中定义全局变量,如果该变量使用关键字static作为存储类别说明符,则它的作用域是()
A . 整个程序范围
B . 定义该变量的源文件范围
C . main函数内部
D . 从定义该变量的位置开始直至程序结束
-
要在Visual C++应用程序内使用ADOActiveX数据对象,应该选择OLEDB作为连接类型,然后再应用程序中使用()类。
A . A、DAO
B . B、OLEDB
C . C、ADO
D . D、OLE
-
若在应用程序的标准模块、窗体模块和过程模块Sub1的说明部分,分别用"PublicGAsInteger"、"PrivateGAsInteger"和"DimGAsInteger"语句说明了三个同名变量G。如果在过程Sub1中使用赋值语句"G=3596",则语句是给在()说明部分定义的变量G赋值。
A . 标准模块、窗体模块和过程Sub1
B . 标准模块
C . 窗体模块
D . 过程Sub1
-
在C语言中,不使用命名空间,但在C++程序中,一定要使用命名空间。
A . 正确
B . 错误
-
说明在嵌入式汇编程序中访问C程序变量的一般方法。
-
要在Visual C++应用程序内使用ADO ActiveX数据对象,应该选择OLEDB作为连接类型,然后再应用程序中使用()类。
A . A、DAO
B . B、OLEDB
C . C、ADO
D . D、OLE
-
接蒸汽时一定要先排掉管内液体,并且要先暖管,开启阀门一定要缓慢,有水击、震动时说明管内有液体,要尽快排掉。
A . 正确
B . 错误
-
若在应用程序的标准模块、窗体模块和过程 Sub1的说明部分,分别用“Public G as Integer”、“Private G as Integer”、“Dim G as Integer”语句说明了三个同名变量G。如果在过程Sub1中使用赋值语句“G=35”,则该语句是给在______ 说明部分定义的变量G赋值。
-
在一个 C++ 源程序文件中定义的全局变量的有效范围是:
-
若在一个C源程序文件中定义了一个允许其他源文件引用的实型外部变量a,则在另一文件中可使用的引用说明是【 】。
A、extern static float a;
B、float a;
C、extern auto float a;
D、extern float a;
-
在C++中,3种派生方式的说明符号为()()(),如果不加说明,则默认派生方式为().
-
在Verilog程序中,如果没有说明输入、输出变量的数据类型,试问它们的数据类型是什么?
-
阅读下列说明和C++程序,将应填入(n)处的字句写在对应栏内。【程序1说明】 程序1中定义了数组的类模
阅读下列说明和C++程序,将应填入(n)处的字句写在对应栏内。
【程序1说明】
程序1中定义了数组的类模板,该模板使得对于任意类型的二维数组,可以在访问数组元素的同时,对行下标和列下标进行越界判断,并给出相应的提示信息(C++语言本身不提供对下标越界的判断)。
【程序1】
include < iostream. h >
template < class T > class Array2D;
template < class T > class Array2DBody {
friend (1);
T * tempBody;
int iRows, iColumns, iCurrentRow;
Array2DBody(int Rows,int Cols) {
tempBody =(2);
iRows = Rows;
iColumns = Cols;
iCurrentRow = -1;
}
public:
T& operator[ ] (int j){
bool row_ error, column_ error;
row_ error = column_ error = false;
try {
if (iCurrentRow < 0||iCurrentRow > = iRows)
row_ error = true;
if(j < 0||j > = iColumns)
column_error = true;
if(row_error = = true [ [ column_ error = = true)
(3);
}
catch(char) {
if (row_error = = true)
cerr < < "行下标越界"[" < < iCurrentRow < < "]";
if(colmnn_error = = true)
cerr< <"列下标越界[" < <j< <"]";
cout < < "\n";
}
return tempBody[ iCurrentRow * iColumns + j ];
}
~ Array2 DBody () { delete [ ] tempBody; } }; template < class T > class Array2D {
Array2DBody < T > tBody;
public:
Array2DBody < T > & operalor[ ] (int i) {
tBody, iCurreutRow = i;
(4);
Array2D(int Rows,int Cols): (5) {} };
void main()
{
Array2D <int> al (10,20 );
Array2D <double> a2(3,5);
int bl;
double b2;
b1=a1[-5][10];//有越界提示:行下标越界[-5]
b1=a1[10][15];//有越界提示:行下标越界[10]
b1=a1[1][4];//没有越界提示
b2=a2[2][6];//有越界提示:列下标越界[6]
b2=a2[10][20];//有越界提示:行下标越界[10]列下标越界[20]
b2=a2[1][4];//没有越界提示
}
-
若一个C程序中说明一个全局变量int ⅰ;(在所有函数之外说明的),则该程序任何一点都可引用全局变量ⅰ。()
是
否
-
阅读以下说明和C++程序,将应填入(n)处的语句写在的对应栏内。 【说明】 以下程序的功能是计算三角形
阅读以下说明和C++程序,将应填入(n)处的语句写在的对应栏内。
【说明】
以下程序的功能是计算三角形、矩形和正方形的面积并输出。
程序由4个类组成:类Triangle、Rectangle和Square分别表示三角形、矩形和正方形;抽象类Figure提供了一个纯虚拟函数getArea(),作为计算上述3种图形面积的通用接口。
【C++程序】
include<iostream.h>
include<math.h>
class Figure {
public:
virtual double getArea()=0; //纯虚拟函数
};
class Rectangle:(1){
protected:
double height;
double width;
public:
Rectangle() {};
Rectangle(double height,double width) {
this->height=height;
this->width=width;
}
double getArea() {
return (2);
}
};
class Square:(3){
public:
Square(double width){
(4);
}
};
class Triangle:(5){
double la;
double lb;
double lc;
Public:
Triangle(double la, double lb, double lc) {
This->la=la; this->lb=lb; this->lc=lc;
}
double getArea() {
double s = (la+lb+±c)/2.0;
return sqrt(s,(s-la)*(s-lb)*(s-Ic));
}
};
void main() {
Figure*figures[3]={
new Triangle(2,3,3), new Rectangle(5,8), new SqUare(5));
for(int i=0;i<3;i++){
cout<<"figures["<<i<<"]area="<<(figures[i])->getArea()<<endl;
}
}
-
阅读下列程序说明和C++代码,将应填入(n)处的字句写在对应栏内。 [说明] ①定义私有数据成员code、en
阅读下列程序说明和C++代码,将应填入(n)处的字句写在对应栏内。
[说明]
①定义私有数据成员code、english分别用于表示考生的编号、英语成绩,它们都是int型的数据。
②完成成员函数void Student::inputinformation()的定义,该函数用于用户输入一个考生对象的信息,输入格式如下:
输入编号:
英语成绩:
计算机成绩:
③利用已实现的类Student的成员函数,完成函数void firstname(Student *A[],int uum)的定义,该函数根据考生信息A[],输出num个考生中总分最高者的编号及其相应的总分,在此不考虑总分相同的情况。
源程序文件test1.cpp清单如下:
include < iostream. h >
class Student
(1)
int computer;
int total;
public
void getinformation();
void computesum();
int getcode();
int gettotalscore();
~Student();
};
void Student: :getinformation()
{
(2)
cout <<"英语成绩:";
cin> >english;
cout <<"计算机成绩:";
cin > > computer;
void Student:: computesum ()
total = english + computer;
cout <<"编号" << code <<"总分:" <<total << endl;
int Student::getcode()
return code;
}
int Student:: gettotalscore ()
{
return total;
}
void firstname(Student * A[] ,int num)
{
(3)
tempsum = (* A[0] ). gettotalscore();
for(int i=1; i <num; i++)
{
if (((* A[i] ). gettotalscore() ) > tempsum)
{
tempcode = (* A[i] ). getcode();
tempsum = (* A[i] ). gettotalscore();
}
}
cout <<"总分最高者--" << tempcode <<":" << tempsum <<endl;
}
void main()
{
Student * A[3];
int i,n =3
for(i=0;i<n;i ++)
A[i] = new Student;
A[i] -> getinformation()
for(i=0;i<n;i ++)
{
A[i] -> computesum()
firstname (A,3 );
}
-
阅读以下说明和C++程序,将应填入(n)处的字句写在对应栏内。【C++程序】include < stdio. h >include
阅读以下说明和C++程序,将应填入(n)处的字句写在对应栏内。
【C++程序】
include < stdio. h >
include < string. h >
define Max 1000
class Bank
{
int index;
char date [Max] [10]; // 记录交易日
iht amount[Max]; // 记录每次交易金额,以符号区分存钱和取钱
int rest[ Max]; // 记录每次交易后余额
static iht sum; // 账户累计余额
public:
Bank() {index =0;}
void deposit(char d[ ] , int m) //存入交易
{
strcpy (date [ index ], d);
amount[ index] = m;
(1);
rest[ index] = sum;
index++;
}
void withdraw (char d[ ], int m) //取出交易
{
strcpy(date[ index] ,d);
(2);
(3);
rest[ index] = sum;
index++;
}
void display();
};
int Bank:: sum = 0;
void Bank:: display () //输出流水
{
int i;
printf("日期 存入 取出 余额\n");
for (4)
{
printf(" %8s" ,date[i] );
if (5)
printf(" %6d" , -amount[i] );
else
printf("%6d ",amount[i] );
printf("% 6d\n" ,rest[i] );
} }
void main()
{
Bank object;
object. deposit ("2006.2.5", 1 00 );
object. deposit("2006.3.2" , 200);
object. withdraw("2006.4.1", 50);
object. withdraw("2006.4.5", 80);
object. display ();
}
本程序的执行结果如下:
日期 存入 取出 余额 2006.2.5 100 100
2006.3.2 200 300
2006.4.1 50 250
2006.4.5 80 170
-
【单选题】在C++中,不加说明,则默认的继承方式是 。
A.public
B.private
C.protected
D.public或protected
-
打电话时, 要先介绍自己, 再说明要找谁,商务电话三分钟以内结束为宜。()
是
否
-
2、在C++中,三种派生方式的说明符号为 ,若不加说明,则默认的派生方式为 。
-
6、在一个C++源程序文件中定义的全局变量的有效范围是:
A.该C++程序的所有源程序文件
B.本源程序文件的全部范围
C.从定义变量的位置开始到本源程序文件结束
D.函数内部全部范围