更多"在下面横线处填上正确的内容,完成类的定义。 class Base &n"的相关试题:
[填空题]下面程序是一个堆栈的类模板,在横线处填上适当语句,完成类模板的定义。
#define MAXSIZE 100
template <class T>
class Stack
{
T s[MAXSIZE];
int top;
public:
stack( )
{
top=1;
}
void push(T newValue)
{
if(top<MAXSIZE)
{
top=top+1;
s[top]=newValue;
}
else
cout<<"堆栈满,无法进栈"<<end1;
}
void pop( );
};
【12】
{
if(top>1)
{
cout<<s[top]<<end1;
top=top-1;
}
else
cout<<"堆栈空! "<<end1;
}
[填空题]在下面程序横线处填上适当内容,使程序输出为: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;
}
[填空题]在下面程序的横线处填上适当的内容,使程序执行后的输出结果为1/2005。
#include <iostream.h>
using namespace std:
class Date
public:
Date (int m=1,int y=0):month(m .year(y}{}
void Print( ) {cout<<month<<"/"<<year<<end1;}
______operator+(const Date& d1,const Date&d2;
private:
int month year;
};
______operaror+(const Date&d1,const Date& d2)
int year, month;
year=d1.year+d2.year;
month=d1.month+d2.month;
year+=(month-1)/12;
month=(month-1)%12+l;
return Date{month, year}:
}
void main( )
{
Date d1(3,2004),d2,d3(10);
d2=d3+d1;
d2.Print( );
}
[填空题]在下面程序的横线处填上适当的内容,使程序执行后的输出结果为ABCD。
#include <iostream.h>
using namespace std;
class A
{
public: A( ) {cout<<’A’;
};
class B:______
{
public: B( ) {cout<<’B’;}
};
class C:______
{
public: C(} cout<<’C’;}
};
class D:public B, public C
{
public: D( ){cout<<’D’;}
};
void main( ){D obj;}
[填空题]在下面程序的横线处填上适当的内容,使程序执行后的输出结果为ABCD。
#include <iostream>
using namespace std;
class A
public: A( ) cout<<’A’;
;
class B: 【14】
public: B( )cout<<’B’;
class C: virtual public A
public: C( )cout<<’C’;
class D:public B, public C
public: D( ) cout<<’D’;
;
void main( ) D obj;
[填空题]在下面程序的横线处填上适当的内容,使程序执行后的输出结果为ABCD。
#include <iostream>
using namespace std;
class A
public: A( ) cout<<’A’;
;
class B: 【11】
public:B( ) cout<<’B’;
;
class C: 【12】
public: C( )cout<<’C’;
;
class D:public B,public C
public:D( ) cout<<’D’;
;
void main( ) D obj;
[填空题]在下面函数的横线处填上适当的内容,使该函数能够利用递归方法求解字符串str的长度 (不得使用系统提供的字符串处理函数)。
int GJetLen(char*str)if( 【8】 ) return 0;
else return 1+GetLen (str+1);
[填空题]在下面横线处,填上对修辞方法及其作用的正确表述.(*
A. A.运用了反复的修辞手法,表达了对总理的无限眷念之情
B.运用了排比的修辞手法,使诗歌显得更有气势
C.运用了夸张的修辞手法,充分表达对总理的思念
D.运用了对偶的修辞手法,使诗歌前后照应浑然一体
[单项选择]在下列横线处应添加的语句是( )。
class Base public:void fun( ) cout<<"Base::fun"<<end1; ;
class Derived:public Base
public:
void fun( )
//显示调用基类的fun函数
cout<<"Derived::fun"<<end1;
;
A. Derived::fun
B. Base::fun();
C. Pubic::fun
D. fun();
[填空题]在下面函数的横线处填上适当的内容,使该函数能够利用递归方法求解字符串str的长度(不得使用系统提供的字符串处理函数)。
int GetLen(char*str)
{
if(______) return 0;
else return 1+GetLen(str+1);
}