填空题以下程序的输出结果是{{U}} {{/U}}。
#include<iostream.h>
void fun( )
{ static int a=0;
a+=2;
cout < < a < < " ";}
void main( )
{ int cc;
for(cc=1;cc<4;cc++)
fun( ) ;
cout < < endl;}
填空题设文件temp.txt 已存在,则以下的打印结果是 【15】 #include <iostream> #include <fstream> using namespace std; int main() ofstream outf ("temp.txt",ios base: :trunC) ; outf<<"How you doing"; outf.close(); ifstream inf("temp.txt"); char str[20]; inf>>str; inf.close(); cout<<str; return 0;
填空题下面程序的输出为______。 #include <iostream.h> void main() int a[10],i,k=0; for(i=0;i<0;i++) for(i=1;i<4;i++) cout<<k<<endl;
填空题友元类的所有成员函数都是另一个类的 。
填空题算法的基本特征是可行性、确定性、______和拥有足够的情报。
填空题一个类中有 【9】 个析构函数。
填空题要采用“cin,tout”进行输入输出时,必须包含的头文件是【 】。
填空题从实现的角度划分,C++所支持的两种多态性分别是{{U}} 【7】 {{/U}}时的多态性和运行时的多态性。
填空题若下列程序运行时输出结果为 1,A,10.1 2,B,3.5 请将程序补充完整。 #include<iostream> using namespace std; void test(int a,char b,double c) cout<<a<<','<<b<<','<<c<<end1; int main() void test(int,char,double ______); test(1,'A',10. 1); test(2,'B'); return 0;
填空题有以下程序
#include<iostream>
using namespace std;
class MyClass
{
public:
static int s;
MyClass();
void SetValue(int val);
};
int MyClass::s=0;
MyClass::MyClass()
{
S++;
}
void MyClass::SetValue(int val)
{
S=val:
}
int main()
{
MyClass my[3],*p;
p=my;
for(int k=0;k<3;k++)
{
P->Set Value(k+1);
p++;
}
cout<<MyClaSS::s<<endl;
retum 0;
}
运行后的输出结果是{{U}} 【12】 {{/U}}。
填空题类是一个支持集成的抽象数据类型,而对象是类的{{U}} 【3】 {{/U}}。
填空题重载函数的函数名称相同,但函数的实现和功能不同,系统是靠{{U}} 【12】 {{/U}}来决定采用哪个函数。
填空题定义一个函数时,若只允许函数体访问形参的值而不允许修改它的值,则应把该形参声明为
________
类型。
填空题下列程序的输出结果是 【8】 #include<iostream>using namespace std;int int main () int a =10; getVar( cout<<a<<end1; return 0;
填空题将x+y*z中的“+”用成员函数重载,“*”用友元函数重载应写为
________
。
填空题程序的结果为______。 #include"iostream.h" template<typename T> T total(T*data) T s=0; while(* data) s+=*data++; return s; int main( ) int x[ ]= 2,4,6,8,0,12,14,16,18 ; cout<<total(x); return 0; cout<<endl;
填空题如果表达式--x中的“--”是重载的类运算符,采用运算符函数调用格式,及表达式还可以表示为______。
填空题分析以下程序执行结果{{U}} [14] {{/U}}。
#include<iostream.h>
int f (int x, int y){
return x,y;
}
double f (double x, double y) {
return x,y;
}
void main() {
int a=4, b=6;
double c=2.6, d=7.4;
cout<<f (a, b) <<","<<f (c, d) <<end1;
}
填空题C++语言支持的两种多态性分别是编译时的多态性和【 】的多态性。
填空题下面是复数类complex的定义,其中作为友元函数重载的运算符“--”的功能是将参数对象的实部减1,然后返回对该对象的引用:请补充完整。 class complex private: int real; int imag; public: complex(int r=0,int i=0):real(r),imag(i) void show() cout<<real<<(imag<0?"-":"+")<<imag<<'i'; 【15】 ; ; complex& operator--(complex &C) c.real--; return c;
