更多"请将下列模板类Data补充完整。 template clas"的相关试题:
[填空题]下列程序将x、y和z按从小到大的顺序排列,请将下面的函数模板补充完整。 template<class T>
void order( 【13】 )
T a;
if(>y)
a=X; x=y;y=a;
if (y>z)
a=y: y=Z:Z=a:
if(x>y)
a=X; x=y;y=a;
[填空题]
类Sample的构造函数将形参data赋值给数据成员data。请将类定义补充完整。
class Sample{
public:
Sample(int data=0);
Private:
Int data;
};
Sample::Sample(int data){
【10】
}
[填空题]下列程序的功能是创建了一个实现5个“Hello!”的线程并启动运行,请将程序补充完整。
public class Test extends Thread
public static void main(String[ ] args)
Test t = new 【10】 ;
t. start( );
public void run( )
int i = 0;
while (true)
System. out. println( "Hello" );
if (i++ ==4) break;
[填空题]下列程序的功能是创建了一个显示5个"Hello!"的线程并启动运行,请将程序补充完整。
public class ThreadTest extends Thread
public static void main(String args[])
ThreadTest t=new 【12】 ;
t.start( );
public void run( )
int i=0;
while(true)
System.out.println("Hello!");
if(i++==4) break;
[填空题]补充完整下面的模板定义:
template<class Type> //Type为类型参数
class Xtwo{ //由两个Type类型的数据成员构成的模板类
Type a;
Type b;
public:
Xtwo(Type aa=0,Type bb=0):a(aA) ,b(bB) { }
int Compare( ){ //比较a和b的大小
if(a>B) return 1;
else if(a==B) return 0;
else return-1;
}
Type Sum( ){return a+b;} //返回a和b之和
Type Mult( ); //函数声明,返回a和b之乘积
};
template<class Type>
______ ::Mult( ){return a*b;} //Mult函数的类外定义
[填空题]
补充完整下面的模板定义:
template<class Type> //Type为类型参数
class Xtwo{ //由两个Type类型的数据成员构成的模板类
Type a;
Type b;
public:
Xtwo(Type aa=0,Type bb=0):a(aa),b(bb){}
int Compare( ){ //比较a和b的大小)
if(a>b) return 1;
else if(a= =b) return 0;
else return -1;
}
Type Sum( ){return a+b;)//返回a和b之和
Type Mult( ); //函数声明,返回a和b之乘积
};
template<class Type>
______::Mult( ){ return a*b;}//Mult函数的类外定义
[填空题]请按下面注释的提示,将类B的构造函数定义补充完整。
classA
int a;
public:
A(int aa=0) a=aa;)
;
Class B:public A
int b;
A c;
public:
//用aa初始化基数A,用aa+1初始化类对象成员c
B(int aa): (b=aa+2)
;
[填空题]请将程序补充完整。
importjava.awt.*;
publicclassFirstFrameextendsFrame
publicstaticvoidmain(Stringargs[])
FirstFramefr=newFirstFrame("Firstcontainer!");
fi.setSize(240,240);
fi.setBackground(Color.yellow);
publicFirstFrame(StringStr)
super(Str);
[填空题]
请将下面程序补充完整。
public class PowerCalc{
public static void main(String[]args){
double x=5.0;
System. out. println(x+"to the power 4 is"+power(x, 4));
System. out. println("7. 5 to the power 5 is"+power(7.5, 5));
System. out. println("7.5 to the power 0 is"+power(7.5, 0));
System. out. println("10 to the power -2 is"+power(10, -2));
}
static double 【11】 (double x, int n){
if(n>1)
return x * power(x, n-1);
else if(n<0)
return 1.0/power(x, -n);
else
return n==0 1.0:x;
}
}
[填空题]请将程序补充完整。
import java.awt.*;
public class FirstFrame extends Frame {
public static void main(String args[]){
FirstFrame fr=new FirstFrame("First container!");
fr.setSize(240,240);
fr. setBackground(Color.yellow);
【15】
}
public FirstFrame(String str){
super(str);
}
}
[填空题]请将程序补充完整。
import java.awt.*;
public class FirstFrame extends Frame
public static void main(String args[])
FirstFrame fr=new FirstFrame("First container!");
fr.setSize(240,240);
fr.setBackground(Color.yellow);
【15】
public FirstFrame(Strings str)
super[str);
)
[填空题]请将程序补充完整。
import java.awt.*;
public class FirstFrame extends Frame
public static void main(String args[])
FirstFrame fr = new FirstFrame("First container!");
fr. setSize(240,240);
fr. setB ackground(Color, yellow);
【15】
public FirstFrame(String str)
super(str);