填空题下面程序输出的结果是{{U}} 【10】 {{/U}}。
#include <iostream>
using namespace std;
class A {
public:
virtual void show() {cout<<"A!";
};
class B: public A {
public:
void show() {cout << "B!";}
};
class C: public B{
public:
void show(){cout << "C!";}
};
void show_info(A }
void main() {
A ia; B ib; C ic; show_info(ia);show_info(ib); show_info(ic); }
填空题类time可以输出12小时或24小时制的时间,现需要设计一个缺省构造函数,缺省值为0时0分0秒。该缺省构造函数为______。
#include<iostream.h>
class Time
{
int h,m,s;
public:
Time(int hour=0,int min=0,int sec=0){settime(hour,min,sec);}
void settime(int hour,int min,int sec){h=hour;m=min;s=sec;}
void show24( )
{ cout<<(h<10?"0":"")<<h<<":"<<(m<10?"0":"")<<
m<<":"<<(s<10?"0":"")<<s<<endl;
}
void showl2( )
{ int temp=(h= =0 || h= =12)? 12:h%12;
cout<<(temp<10?"0":"")<<temp<<":"<<(m<10?"0":"")
<<m<<":"<<(s<10?"0":"")<<s<<((temp>0
}
};
void main( )
{
Time t(15,43,21);
t.showl2( );
t.show24( );
}
填空题表达式8&3的结果是
________
。
填空题假设int a=1,b=2;,则表达式(++a/b) * b--的值为{{U}} {{/U}}。
填空题当输入10,11,12时,下面程序运行结果是{{U}} 【6】 {{/U}}。
#include <iostream>
using namespace std;
int main()
{
int a,b,c,max;
cin>>a>>b>>c;
max=a;
if (max<B)
max=b;
if (max<C)
max=c;
cout<<max<<end1;
return 0;
}
填空题设有定义语句:int a=12;,则表达式a*=2+3的运算结果是 【7】 。
填空题派生类构造函数的执行顺序是先执行{{U}} 【12】 {{/U}}的构造函数,然后执行成员对象的构造函数,最后执行{{U}} 【13】 {{/U}}的构造函数。
填空题将一个函数声明为一个类的友元函数必须使用关键字 【8】 。
填空题软件工作三要素包括方法、工具和过程,其中,______支持软件开发的各个环节和控制和管理。
填空题下面程序的输出结果为______。 #include <iostream.h> void main() int a; int //变量引用 b=10; cout<"a="<<a<<endl;
填空题有以下程序:
#include <iostream>
using namespace std;
class Sample
{
private:
int n;
public:
Sample(int i){n=i;}
void print()
{
cout<<"1:n="<<n<<",";
}
void print() const
{
cout<<"2:n="<<n<<end1;
}
};
int main()
{
Sample a(10);
const Sample b(20);
a.print();
b.print();
}
上述程序运行后的输出结果是{{U}} 【13】 {{/U}}。
填空题若有整型变量x=2,则表达式x<<2的结果是{{U}} {{U}} {{/U}} {{/U}}。
填空题设有以下程序:
#include<iostream>
using namespace std;
int main()
{
int a,b,k:4,m=6,*p1=&k,*p2=&m;
a=p1==&m;
b=(*p1)/(*p2)+7;
cout<<a<<b<<end1;
return 0;
}
执行该程序后,a的值为
________
,b的值为
________
。
填空题类是用户定义的类型,具有类类型的变量称作 [11] 。
填空题函数中的形参和调用时的实参都是变量时,参数传递方式为{{U}} [9] {{/U}}。
填空题若已定义fun函数的功能是:在第一个循环中给前10个数组元素依次赋1、2、3、4、5、6、7、8、9、10;在第二个循环中使a数组前10个元素中的值对称折叠,变成1、2、3、4、5、5、4、3、2、1。请填空。 fun( int a[]) int i; for(i=1;i<=10;i++)______=i; for(i=0;i<5;i++) ______=a[i];
填空题C++语句const char * const p="hello";,所定义的指针p和它所指的内容都不能被{{U}} {{/U}}。
填空题下列软件系统结构图的宽度为________。
填空题下面程序的输出结果是{{U}} {{U}} {{/U}} {{/U}}。
#include<iostream.h>
#include<math.h>
class point
{
double x;
double y;
public:
point(doublea,d double B)
{
x=a;
y=b;
}
friend double distance (point a,point B) ;
};
double distance (point a,point B)
{
return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));
}
void main()
{
point p1(1,2);
point p2(5,2);
cout<<distance(p1,p2)<<end1;
}
填空题在C++中,类的成员有3种访问权限,它们分别是公有、 【11】 和私有。
