填空题请在mian函数中填空使下面程序的输出结果为1 1。 #include<iostream.h> class A private: int a; int b; public: A( ):a(0) ,b(1) void show( ) cout < < a < < " " < < b; ; class B private: int a; int c; public: B( ):a(1),c(1) void show( ) cout < < a < < " " < < c; ; class C:public A,public B ; void main( ) C cc; 【12】
填空题根据下列程序的执行结果,可以断定划线部分的修饰符应为{{U}} 【14】 {{/U}}。
执行结果:
i9a football is created.
a football is created.
i=10
a football is destroyed.
a football is created.
i=20
a football is destroyed.
a football is destroyed.
源程序:
# inelude<iostream. h>
class Football
{
public:
Football() {cout<<"a football is created. "<<end1; }
~Football() {cout<<"a football is destroyed. "<<end1;
};
void func(int i)
{
______ Football f1;
Football f2;
cout<<"i= "<<i<<end1;
}
void main()
{
func(10);
func(20);
}
填空题多态性分两类:编译时的多态性和______。
填空题下面是一个递归函数,其功能是使数组中的元素反序排列,请将函数补充完整。 void reverse(int * a,int size) if(size<2)return; int k=a[0]; a[0]=a[size-1]; a[size-1]=k;reverse(a+l,______);
填空题有如下循环语句:
for(inti=50;i>20;i-=2)cout<<i<<",";
程序运行时循环体的执行次数是______。
填空题以下程序的输出结果是 。 #include<iostream.h> void main( ) int a=0; a+=(a=8) ; cout < < a;
填空题阅读下面程序:
#include <iostream.h>
int fun2(int m)
{
if(m%3==0)
return 1;
else
return 0;
}
void fun1(int m, int
for (i=1; i<m; i++)
if(fun2(i))
S=S*i;
}
void main()
{
int n=9, s=2;
fun1(n, s);
cout<<s<<end1;
}
该程序的运行结果是{{U}} 【12】 {{/U}}。
填空题______允许用户为类定义一种模式,使得类中的某些数据成员及某些成员函数的返回位能取任意类型。
填空题已知如下程序的输出结果是23,请将画线处缺失的部分补充完整。 #include<iostream> using namespace std; class MyClass public: void Print( )consteout<<23; ; int main( ) MyClass*P=new MyClass( ); ______.Print( ); return 0;
填空题执行下面程序输出的是{{U}} 【15】 {{/U}}。
#include <iostream>
using namespace std;
template <typename T>
T total(T *data){
Ts=0;
while( *data) s+=*data++;
return s;
}
int main(){
int s[]={1,3,5,7,0,2,4,6,8};
cout<<total(s);
return 0;
}
填空题下列程序中的重载函数disp( )发生错误,错误原因是______。 #include<iostream.h> class Sample private: int m; static int st; public: Sample(int a)m=a;st+=a; static void disp( )cout<<m<<endl; static void disp(Sample input) cout<<input.m<<endl;; int Sample::st=2; void main( ) Sample First(2),Second(4); Sample::disp( ); Sample::disp(Second);
填空题内联函数是通过 【6】 来实现的,因此内联函数是真正的函数。
填空题结构化程序设计方法的主要原理的是 [2] 。
填空题在C++中,打开一个文件,就是将这个文件与一个 【10】 建立关联,关闭一个文件,就是取消这种关联。
填空题以下程序的执行结果是{{U}} 【11】 {{/U}}。
#include<iostream.h>
int f(int b[],int n)
{
int i,r=1;
for(i=0;i<n;i++)
r=r*b[i];
return r;
}
void main()
{
int x,a[]={2,3,4,5,6,7,8,9};
x=f(a,3);
cout<<x<<endl;
}
填空题树L中,度为1、2、3、4、5和6的节点个数为6、4、3、3、5、1,则L中叶子的个数是 【2】 。
填空题一个类中有{{U}} 【9】 {{/U}}个析构函数。
填空题在下面横线上填上适当的语句,完成程序。 #include <iostream> using namespace std; class Base int x; public: Base(int i) x=i; ~Base() ; class Derived: public Base public: ______∥完成类 Derive 构造函数的定义 ; int main() Derived Obj; return 0; 在横线处应填入的语句是 【11】 。
填空题以下程序的输出结果是
________
。
char s[ ]="XYZQ";
void main(){
char *p;
for(p = s; p < s+4; p++)
cout<<p<<end1;
}
填空题假设a,b,和c都是整型变量,且值都是5,执行a-=++b+c--;则a,b,和c的结果分别是{{U}} [5] {{/U}}。
