C++语言程序设计2021年1月21日每日一练
填空题下列程序的输出结果是{{U}} {{U}} {{/U}} {{/U}}。
#include <iostream>
using namespace std;
class base {
public:
int n;
base(iht x) {n=x;}
virtual void set(int m) {n=m;cout<<n<<'';}
};
class deriveA: public base {
public:
deriveA(int x):base(x) {}
void set(int m){n+=m;cout<<n<<'';}
}:
class deriveB:public base {
public:
deriveB(int x):base(x) { }
void set(int m) {n+=m;cout<<n<<'';}
};
int main()
deriveA d1(1);
deriveB d2(3);
base *pbase;
pbase=
pbase->set(1);
pbase=
pbase->set(2);
return 0;
填空题在面向对象方法中,允许作用于某个对象上的操作称为{{U}} 【3】 {{/U}}。
单选题数据库管理系统是位于用户与操作系统之间的一个数据管理软件,以下不属于它的基本功能的是( )。
问答题请使用VC6或使用[答题]菜单打开考生文件夹proj2下的工程prog2,其中定义了Stack类和Entry类。Stack是一个基于链式存储结构的栈,Entry表示存储在栈中的数据顶。请在横线处填写适当的代码并删除横线,以实现上述类定义。此程序的正确输出结果应为:
0 1 2 3 4 5 6 7 8 9
9 8 7 6 5 4 3 2 1 0
注意:只在横线处填写适当的代码,不要改动程序中的其他内容,也不要删除或移动“//****found****”。
#include <iostream>
using namespace std;
class Entry {
public:
Entry* next;
int data;
//********** found**********
Entry (Entry * n, int d): ______, data(d) {}
};
class Stack {
Entry* top;
public:
Stack() : top(0) {}
~Stack()
{
while (top!= 0)
{
Entry* tmp = top;
//********** found**********
top =______;
delete tmp;
}
}
void push (int data)
{
//********** found**********
top = new Entry(______, data);
}
int pop ( )
{
if (top = 0) return0;
//********** found**********
int result = ______;
top = top->next;
return result;
}
};
int main ( )
{
int a[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
Stack s;
int i = 0;
for (i = 0; i < 10; i++) {
cout << a[i] << ";
s.push(a[i]);
}
cout << endl;
for (i = 0; i <10; i++) {
cout << s.pop() <<'';
}
cout << endl;
return 0;
}
填空题下面程序的输出结果为{{U}} 【8】 {{/U}}。
#include<iostream.h)
Void main()
{
int num=0,i=8;
do{
i--;
num++
}while(--i);
cout<<num<<end1;
}
填空题使用如setw ()的操纵符对数据进行格式输出时,应包含 【7】 文件。
填空题执行下列语句后,变量sum的值是______。 int sum=0; for(int i=1;i<=3;i++) for(int j=1;j<=i;j++) sum++;
单选题有如下程序:
#include
usingnamespacestd;
classTestClass
{public:
virtualvoidfunl()
{coutfun1();
p->fun2();
return0;}
该程序执行后的输出结果是( )。
单选题下列关系运算中,能使经运算后得到的新关系中属性个数多于原来关系中属性个数的是
____
。