1 8 9 11 12 13 15!16 20 21 23 24 25 26 28 29 31 37 (三道没号的) 27 29 30 31 32 1 2 6 7 无号41 44 45 4 6 7 8 10 12 20 37 无号 30 31 33
1)
下列关于对象概念的描述中,(a)是错误的。
A. 对象就是C语言中的结构变量
B. 对象代表着正在创建的系统中的一个实体
C. 对象是一个状态和操作(或方法)的封装体
D. 对象之间的信息传递是通过消息进行的
2)
#include
#include
void main()
{
cout.fill('*');
cout.width(10);
cout<<"123.45"<
#define SQR(x) x*x
void main()
{
int a=10,k=2,m=1;
a/=SQR(k+m);
cout<
{
//This is my first program
cout<<"My first program in C++";
}
这段C++程序的输出是(d)。
a)
My first program in C++
b)
This is my first program
c)
My first Program in C
d)
None of the above
8)
#include
class example
{
private:
static int num;
public:
example(){num++;cout<
class One
{
public:
void display(){cout<<"1"<<"";}
};
class Two:public One
{
public:
void display(){cout<<"2"<<"";}
};
void main()
{
One first;
Two second;
first.display();
second.display();
One *p=&first;
p->display();
p=&second;
p->display();
}
在C++中,以上程序的运行结果为(c)。
a)
1 1 1 2
b)
1 2 1 2
c)
1 2 1 1
d)
2 1 1 2
14}
15)
对于C++类
class date
{
private:
int day,month,year;
public:
void setdate(int,int,int);
print();
};
下列描述是正确的(d)。(选择两项)
a)
setdate()函数内参数没有写变量名,因而它是错误的;
b)
year是私有的,print()是公有的,setdate()可以访问day,而print()不能访问day
c)
setdate()可以访问day,而print()不能访问day
d)
setdate()可以访问day,而print()也可以访问day
16)
在C++中,可以重载的运算符有(d)。
a)
sizeof()
b)
::
c)
.*
d)
++
17)
#include
class date
{
private:
int day ,month,year ;
public:
date(){}
date(int x,int y,int z){day=x;month=y,year=z;}
void set(){day=1;month=10;year=2002;}
void display(){cout<
class A
{
public:
A(){cout<<"A construct";}
};
class B:public A
{
public:
B():A(){cout<<"B construct"<说明符中,被指定为私有的数据可以被以下(c)访问。
a)
程序中的任何函数
b)
其他类的成员函数
c)
类中的成员函数
d)
派生类中的成员函数
22)在C++程序中出现(c)情况时,将引发一个异常。
a)
在main 函数的结尾少了一个大括号
b)
for循环语法错误
c)
被零除或数组溢出
d)
数组没有被赋满值
23)class Employee
{
private :
int a ;
protected:
int b;
public :
int c;
void display();
};
class Director:public Employee
{
public :
void show();
};
在C++中,以下操作正确的是(d)。
a)
void Employee::show(){cout<
class X
{
private:
int num;
public:
X(int intx){num=intx;}
X(X &Y)
{
num=++Y.num;
}
void disp(){cout<设计 的层面上的
b) 子类可以继承父类的公共行为
c) 继承是通过重用现有的类来构建新的类的一个过程
d) 将相关的类组织起来,从而可以共享类中的共同的数据和操作
27)
#include
int &func(int &num)
{
num++;
return num;
}
void main()
{
int n1,n2=5;
n1=func(n2);
cout<
class A
{
public:
A(){}
~A(){cout<<"A destroy";}
};
class B:public A
{
public:
B():A(){}
~B(){cout<<"B destroy";}
};
void main(){B obj;}
上面的C++程序运行的结果是(a)。
a) B destroy
A destroy
b) A destroy
B destroy
c) A destroy
d) B destroy
29)
如果基类A 和A 的派生类B中都有成员函数func();
要在派生类的func()中调用同名的基类的func()成员函数,下列(b)操作下正确的。
a)
func();
b)
A::func();
c)
B::func();
d)
A.func();
30) #include
class A
{
public:
virtual~A(){cout<<"A"<<" ";}
};
class B:public A
{
~B(){cout<<"B"<<" ";}
};
void main()
{
A*pObj=new B;
delete pObj;
}
上面的C++程序的运行结果是(d).
a) A
b) B
c) A B
d) B A
31) 在C++中,(b)一定不能创建类的对象和实例.
a) 虚基类
b) 抽象类
c) 基类
d) 派生类
32)
读下面C++程序:
#include
class line
{
public:
int color;
};
int startx;
class box
{
private:
int upx,upy;
int lowx,lowy;
public:
int color;
int same_color(line a,box b);
void set_color(int c)
{
color = c;
}
void define_line(int x,int y)
{
startx = x;
}
};
int (在此添入) same_color(line a,box b)
{
if(a.color==b.color)
return 1;
return 0;
}
在括号中添入(b),该程序才能正常运行.
a) line::
b) box::
c) line->
d) box->
33)
在c++中,定义了以下的一个类
class example
{
Private:
int data;
Public:
int set(int param);
};
下列操作(d)是正确的
a)
example object;
object.data=10;
b)
example object;
data=object.set(10);
c)
example object;
object.data=object.set(10)
d)
example object;
34)读下面C++程序:
#include
class vehicle
{
protected:
int wheels;
public:
vehicle(int in_wheels=4){wheels=in_wheels;}
int get_wheels(){ return wheels;}
};
void main()
{
vehicle unicyclel;
vehicle unicycle2(3);
cout<<"The unickele1 has"<
class A
{
int num;
public:
A(int i){num=i;}
A(A &a){num=a. num++;}
void print(){cout<
void main()
{
int num=1;
int &ref=num:
ref=ref+2;
cout<
int i=0;
class A
{
public:
A(){i++;}
};
void main()
{
A a,b[3],*c;
c=b;
cout<
class example
{
private:
static int num;
public:
example(){num++;cout<
class A
{public:
A(){cout<<"A construct";}
~A(){cout<<"A constroy";}
};
class B:public A
{
public:
B():A(){cout<<"B construct";}
~B():A()RAVSKYUP{cout<<"B destroy";}
};
void main(){"B destroy";}
上面的C++程序运行的结果是()。(选择一项)
a)
B construct A construct B destroy A destroy
b)
A construct B construct A destroy B destroy
c)
A construct B construct B destroy A destroy
d)
B construct A construct A construct B construct
43
#include
class sample
{
private:
int a,b;
public:
sample(int x ){a=x;b=1;cout<规范 化排列 B. 数据高速转换
C. 避免数据丢失 D. 保证数据完整性
17. 在 C++ 中有以下 4 条语句: static int hot=200;int &rad=hot;hot=hot+100;cout<