题目详情
当前位置:首页 > 计算机考试 > 初级程序员
题目详情:
发布时间:2024-02-12 02:43:07

[简答题]【说明】
在下面程序横线处填上适当的字句,3个(2)空填的是一样的。使其输出结果为:
x=5 x=6
y=7 x=8
z=9
【程序】
#include<iostream.h>
class X1
int x;
(1) ;
X1(int xx=0)x=xx;
(2) void Output( )
cout<<"x="<<x<<end;

;
(3) Y1:public X1
int y;
public:
Y1(int xx=0,int yy=0);X1(xx)y=yy;
(2) void Output( )
(4) Output( );
cout<<"y="<<y<<endl;

;
class Z1:public X1
int z:
(5) ;
Z1(int xx=0,int zz=0):X1(xx)(z=zz;
(2) void Output( )
X1∷Output( );
cout<<"z="<<z<<endl;

;
void main( )

X1 a(5);Y1 b(6,7);Z1 c(8,9);
X1*p[3]=&a,&b,&c);
For(int i=0;i<3;i++)
p[i]->Output( );cout<<endl;


更多"【说明】 在下面程序横线处填上适当的字句,3个(2)空填的是一样的。"的相关试题:

[简答题]【说明】 在下面程序横线处填上适当的字句,3个(2)空填的是一样的。使其输出结果为: x=5 x=6 y=7 x=8 z=9 【程序】 #include<iostream.h> class X1{ int x; (1) ; X1(int xx=0){x=xx;} (2) void Output( ){ cout<<"x="<<x<<end; } }; (3) Y1:public X1{ int y; public: Y1(int xx=0,int yy=0);X1(xx){y=yy;} (2) void Output( ){ (4) Output( ); cout<<"y="<<y<<endl; } }; class Z1:public X1{ int z: (5) ; Z1(int xx=0,int zz=0):X1(xx)(z=zz;} (2) void Output( ){ X1∷Output( ); cout<<"z="<<z<<endl; } }; void main( ) { X1 a(5);Y1 b(6,7);Z1 c(8,9); X1*p[3]={&a,&b,&c); For(int i=0;i<3;i++){ p[i]->Output( );cout<<endl; } }
[简答题]【说明】 在下面函数横线处填上适当的字句,使其输出结果为: 构造函数. 构造函数. 1,2 5,6 析构函数 析构函数. 【C++代码】 #include "iostream.h" class AA { public; AA(int i,int j) {A=i; B=j; cout<<"构造函数./n"; } ~AA( ){ (1) ;} void print( ); private: int A, B; }; void AA∷print( ) {cout<<A<<","<<B<<endl;} void main( ) { AA *a1, *a2; (2) =new AA(1, 2); a2=new AA(5, 6); (3) ; a2->print( ); (4) a1; (5) a2; }
[简答题]【说明】
在下面函数横线处填上适当的字句,使其输出结果为:
构造函数.
构造函数.
1,2
5,6
析构函数
析构函数.
【C++代码】
#include "iostream.h"
class AA
public;
AA(int i,int j)
A=i; B=j;
cout<<"构造函数./n";

~AA( ) (1) ;
void print( );
private:
int A, B;
;
void AA∷print( )
cout<<A<<","<<B<<endl;
void main( )

AA *a1, *a2;
(2) =new AA(1, 2);
a2=new AA(5, 6);
(3) ;
a2->print( );
(4) a1;
(5) a2;

[简答题]在下面程序横线处填上适当内容,使程序执行结果为:40:15程序如下:
#include<iostream.h>
template<class T>
T func(T x,T y)
if(sizeof(T)= =8)
return______;
else
return______;

void main( )
cout<<func(8,5)<<":"<<func(5.0,10.0)<<endl;
int d;cin>>d;

[简答题]在下面程序横线处填上适当内容,使程序执行结果为:
n=9
程序如下:
#include<iostream.h>
template<class T>
class Test

T n;
public:
Test( )
Test(T i)n=i;
Test<T>______(const Test <T> &s)

static Test<T>temp:
______;
return temp;

void disp( )cout<<"n="<<n<<endl;

void main( )

Test<int>t1(4),t2(5),t3;
t3=t1+t2:
t3.disp( );

[填空题]在下面程序横线处填上适当内容,使得程序的输出为9876。
#include <iostream>
using namespace std;
template<class T>
void f( 【12】 )

T t;
for (int i=0;i<n/2;i++)

t=a Ii];
a [i]=a[n-1-i];
a [n-1-i]=t;


int main ( )

int x[]=6,7,8,9;
f(x,4);
for (int i=0;i<4;i++)
cout<<x[i];
cout<<end1;
return 0;

[填空题]在下面程序横线处填上适当内容,使程序输出为:55599。
#include <iostream>
using namespace std;
template <class TYPE>
class HisClass

TYPE data;
public:
HisClass(TYPE a, TYPE b, TYPE C) ;
TYPE getData( ) return data;)

template<class TYPE>
HisClass<TYPE>::HisClass(TYPE a,TYPE b,TYPE C)

【12】
else主f(b>C)
data=b;
else
data=c;

int main( )

HisClass<int> x1(3,4,5),x2(5,3,4),x3(4,5,3),x4(7,8,9),x5(8,7,9);
cout<<x1.getData( )<<x2.getData( )<<x3.getData( )
<<x4.getData( )<<X5.getData( );
return 0;

[填空题]在下面横线上填上适当的语句,完成程序。 #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 Obi; return 0; } 在横线外应填入的语句是______。
[填空题]在下面横线上填上适当的语句,完成程序。 #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; } 在横线处应填入的语句是 【9】
[填空题]在下面横线上填上适当的语句,完成程序。
#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 Obi;
return 0;

在横线外应填入的语句是______。
[填空题]在下面横线上填上适当的语句,完成程序。
#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;

在横线处应填入的语句是 【9】
[简答题]在下面程序横线处填上适当内容,使程序执行结果为:200_ _100。
#include<iostream.h>
template<class T>
T f(______)
if(______)
return x+y;
else
return x*y;

void main( )
cout<<f(10,20)<<"_ _"<<f(45.5,54.5)<<endl;
[填空题]在下面横线上填上适当的语句,完成程序。 #include<iostream> using namespace std; class Base { int x; public: Base(int i){x=i;} ~Base( ){} ); class Derived:public Base { public: ______//完成类Derive构造函数的定义 }; iht main( ) { Derived obj; return 0; } 在横线处应填入的语句是______。
[填空题]在下面横线上填上适当的语句,完成程序。
#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;

在横线处应填入的语句是______。

我来回答:

购买搜题卡查看答案
[会员特权] 开通VIP, 查看 全部题目答案
[会员特权] 享免全部广告特权
推荐91天
¥36.8
¥80元
31天
¥20.8
¥40元
365天
¥88.8
¥188元
请选择支付方式
  • 微信支付
  • 支付宝支付
点击支付即表示同意并接受了《购买须知》
立即支付 系统将自动为您注册账号
请使用微信扫码支付

订单号:

截图扫码使用小程序[完全免费查看答案]
请不要关闭本页面,支付完成后请点击【支付完成】按钮
恭喜您,购买搜题卡成功
重要提示:请拍照或截图保存账号密码!
我要搜题网官网:https://www.woyaosouti.com
我已记住账号密码