更多"【说明】 在下面函数横线处填上适当的字句,使其输出结果为: 构造函"的相关试题:
[简答题]【说明】
在下面函数横线处填上适当的字句,使其输出结果为:
构造函数.
构造函数.
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;
}
[简答题]【说明】
在下面程序横线处填上适当的字句,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;
[填空题]在下面函数的横线处填上适当的内容使该函数能够利用递归方法求解字符串str的长度(不得使用系统提供的字符串处理函数)。
int GetLen(char *str
{
if ( 【6】 ) return 【17】 ;
else return 1+GetLen (str+1);
}
[填空题]在下面函数的画线处填上适当的内容,使该函数能够利用递归方法求解字符串str的长度(不得使用系统提供的字符串处理函数)。
int GetLen(char*str)
if( (6) )return (7) ;
else return 1+GetLen(str+1);
[填空题]在下面横线上填上适当的语句,完成程序。
#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 Obj;
return 0;
在横线处应填入的语句是 【11】 。
[填空题]在下面横线上填上适当的语句,完成程序。
#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:
【10】 完成类Derive构造函数的定义
;
int 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;
在横线处应填入的语句是______。
[填空题]在下面横线上填上适当的语句,完成程序。
#include<iostream>
using namespace std;
class Base
{
int x;
public:
Base(int 0{x=i;}
~Base( ){}
};
class Derived:public Base
{
public:
//完成类Derive构造函数的定义
};
int main( )
{
Derived Obj;
return 0;
}