选择题 下列关于goto语句的描述中,正确的是 。
选择题 已知数组arr的定义如下:
int arr[5]={1, 2, 3, 4, 5};
下列语句中输出结果不是2的是______。
选择题 下列语句中错误的是______。
选择题 若调用一个函数,且此函数中没有return语句,则正确的说法是该函数 。
选择题 关于类模板,下列表述中不正确的是______。
选择题 关于纯虚函数,下列表述中正确的是______。
选择题 以下程序的输出结果是 。
#include<iostream.h>
void main()
{
int a(5),b(6),i(0),j(0);
switch(a)
{
case 5:switch(b)
{
case 5:i++;break;
case 6:j++;break;
default:i++;j++;
}
case 6:i++;
j++;
break;
default:i++;j++;
}
cout<<i<<','<<j<<endl;
}
选择题 一个工作人员可以使用多台计算机,而一台计算机可被多个人使用,则实体工作人员与实体计算机之间的联系是______。
选择题 有如下程序:
# include<iostream>
using namespace std;
class Publication{//出版物类
char name[30];
public:
Publication(char*name='未知名称'){
~strcpy(this->name,name);
}
const char*getName()const{return name;)
virtual const char*getType()const{return'未知类型';}
};
class Book:public Publication{//书类
public:
Book(char*namc):Publication(name){)
viriual const char*getType()const{return '书';}
};
void showPublication(Publication&p){
cout<<p.getType()<<':'<<p.getName()<<endl;
}
int main(){
Book book('精彩人生');
showPublication(book);
return 0;
}
运行时的输出结果是______。
选择题 有如下程序:
#nclude<iostremn>
using namespace std;
class Stack{
public:
Stack(unsigned n=10:size(n){rep_=new int[size];top=O;}
Stack(Stacks):size(s.size)
{
rep_=new int[size];
for(int i=0;i<size;i++)rep_[i]=s.rep_[i];
top=s.top;
}
~Stack(){delete[]rep_;}
void push(int a){rep_[top]=a; top++;}
int opo(){--top;return rep_[top];}
bool is Empty()const{return top==O;}
pavate:
int*rep_;
unsigned size,top;
};
int main()
{
Stack s1;
for(int i=1;i<5;i++) s1.push(i);
Stack s2(s1);
for(i=1;i<3;i++) cout<<s2.pop()<<',';
s2.push(6);
s1.push(7);
while(!s2.isEmpty()) cout<<s2.pop()<<',';
return 0;
}
执行上面程序的输出是
选择题 有以下程序:
#include<iostream>
using namespace std;
Class sample
{
private:
int n;
public:
sample(){}
sample(int m)
{
n=m;
}
sample add(sample s1,samplc s2)
{
this-->n=s1.n+s2.n;
return(*this);
}
void disp()
{
cout<<“n=”<<n<<endl;
}
};
int main()
{
sample s1(10),s2(5),s3;
s3.add(s1,s2);
s3.disp();
return 0;
}
程序运行后,输出的结果是 。
选择题 有如下程序:
#include<iostream>
#include<string>
using namespace std;
class MyBag{
public:
MyBag(string br, string cr):brand(br), color(cr){++count; }
static int GetCount(){return count; }
private:
string brand, color;
static int count;
};
int MyBag::count=0;
int main(){
MyBag one('CityLife', 'Gray');
cout<<one.GetCount();
MyBag*ptr=new MyBag('Coach', 'Black');
cout<<MyBag::GetCount();
return 0;
}
运行时的输出结果是______。
选择题 以下关于友元函数的叙述不正确的是 。
选择题 字面常量42、4.2、42L的数据类型分别是______。
选择题 下面对于友元函数描述正确的是______。
选择题 下列表示纯虚函数的成员函数是______
选择题 有如下程序:
#include<iostream>
using namespace std;
class Bag{
public:
Bag(int p, char s='M'):price(p), size(s) {}
void Show(){cout<<price<<'-'<<size<<''; }
______{cout<<price<<'*'<<size<<'';}
private:
int price;
char size;
};
int main(){
Bag Black(150, 'S');
const Bag White(300, 'L');
Black.Show();
White.Show();
return 0;
}
若运行时的输出结果为“150-S 300*L”,则划线处缺失的部分是______。
选择题 下列关于继承方式的描述中,错误的是______。
选择题 下面程序的结果是______。
#include<iostream.h>
class A
{
int a;
public;
A():a(1){)
void showa(){cout<<a;)
};
class B
{
int a;
public:
B():a(2){)
void showa(){cout<<a;)
};
class C:public A,public B
{
int a;
public:
C():a(3){)
void showa(){cout<<a;}
};
void main()
{
C c;
c.showa();
}
选择题 对关系S和关系R进行集合运算,结果中既包含S中元组也包含R中元组,这种集合运算称为 。
