网友您好, 请在下方输入框内输入要搜索的题目:
题目内容
(请给出正确答案)
下列程序段中有错的是()。 Template//A Type//B Func(Typea,b)//C {retum(a>b)?(a):(
下列程序段中有错的是( )。
Template<class Type> //A
Type //B
Func(Type a,b) //C
{retum(a>b)?(a):(b);} //D
A.A
B.B
C.C
D.D
参考答案
更多 “ 下列程序段中有错的是()。 Template//A Type//B Func(Typea,b)//C {retum(a>b)?(a):( 下列程序段中有错的是( )。Template<class Type> //AType //BFunc(Type a,b) //C{retum(a>b)?(a):(b);} //DA.AB.BC.CD.D ” 相关考题
考题
在下面程序横线处填上适当内容,使程序输出为:55599。 include using namespace std; te
在下面程序横线处填上适当内容,使程序输出为: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){【 】;else主f(b>C)data=b;elsedata=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;}
考题
下列程序是一个函数模板,用于把数组a的每个元素按照逆序放入数组b中。请填空完成该函数模板的定义template<class Type>void Func(Type a[], Type b[],【 】){for(int i=0;i<n;i++)b[n-i-1]=a[i];}
考题
补充完整下面的模板定义: template//Type为类型参数 class Xtwo{//由两个Type类型
补充完整下面的模板定义: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函数的类外定义
考题
( 25 )下列函数模板的定义中,合法的是A ) template Tabs ( T x ) {return x 0 – x: x;}B ) template class Tabs ( Tx ) {retumx0 -x;x;}C ) template Tabs ( T x ) {retum x0 -x;x;}D ) template T abs ( T x ) {returm x0 -x;x;}
考题
有如下程序: include using namespace std; class Monitor{ public: Monitor(cha
有如下程序:include<iostream>using namespace std;class Monitor{public:Monitor(char t):type(t){ }void Print( )const{cout<<"The type of monitor is"<<type private:char type;};class Computer{public:Computer(int i,char C) :______{}void Print( )const{eout<<"The computer is"<<id<<endl;mort.Print( );}private:int id;Monitor mon;};int main( ){const Computer myComputer(101,'B');myComputer.Print( );return 0;}请将程序补充完整,使程序在运行时输出:The computer is 101The type of monitor is B
考题
( 33 )下面程序中对一维坐标点类 Point 进行运算符重载#includeusing namespace std;class point {public:point ( int vaI ) {x=val;}point & operator++ () {x++;retum*this;}print operator++ ( int ) {point ld=*this,++ ( *this ) ;retum old;}int GetX () const {retum x;}private:int x;};int main (){point a ( 10 ) ;cout ( ++a ) .GetX () ;coutA++.GETX () ;retum () ;}编译和运行情况是A )运行时输出 1011B )运行时输出 1111C )运行时输出 1112D )编译有错
考题
下面的函数模板定义中错误的是A.templateB.template Q F(Q x){retum Q+x;) Q F(Q x){return x+x;}C.template<classT>D.template<class T> TF(T x){return x*x;) Bool F(tx){return x>1;)
考题
清使用VC6或使用【答题】菜单打开考生文件夹projl下的工程projl,此工程中包含了类Pets(“宠物”) 和主函数main的定义。程序中位于每个“//ERROR****found ****”之后的一行语句有错误,请加以改 正。改正后程序的输出结果应为: Name:sonny Type:dog Name:John Type:dog Name:Danny Typc:cat Name:John Type:dog 注意:只修改每个“//ERROR ****found ****”下的那一行,不要改动程序中的其他内容。 includeiostream using namespace sm; enum Pets_type{d09,cat,bird,fish}; class Pets{ private: char *name; Pets_type type; public: Pets(const char *name=”sonny”,Pets_type type=dog); Petsoperator=(const Petss); ~Pets; void showeonst;}; Pets::Pets(eonst char$naIne,Pets_type type) //构造函数 { This -name=new char[strlen(name)+1]; strcpy(this一name,name); //ERROR *********found********* type=type; }{ Pets::~Pets//析构函数,释放name所指向的字符串 { //ERROR *********found********* name=’/0‘; } PetsPets::0perator=(const Petss){ if(s==this)//确保不要向自身赋值 return *this; delete[]name; name=new char[strlen(S.name)+1];//ERROR *********found********* strcpy(this一nmne,name); type=S.type: return *this;} void Pets::showconst cout“Name:”name”Type:”: Pets mypetl,mypet2(’’John”,dog);
考题
下列程序的输出结果是【】。 inClude rsing namespace std; template T fun(
下列程序的输出结果是【 】。inClude<iostream>rsing namespace std;template<typename T>T fun(Ta,Tb){retum(a<=b)?a:b;)int main(){cout<<fun(3,6)<<','<<fun(3.14F,6.28F)<<endl; .return 0;}
考题
下列对模板的声明中,正确的是A.templateB.templateC.template
下列对模板的声明中,正确的是A.template<T>B.template<class T1,T2>C.template<class T1,class T2>D.tamplate<class T1;class T2>
考题
有如下函数模板定义: template T func(Tx,Ty){return x*x+y*y;} 在下列对func
有如下函数模板定义: template<class t> T func(Tx,Ty){return x*x+y*y;} 在下列对func的调用中,错误的是A.func(3,5);B.func(3.0,5.5);C.func(3,5.5);D.func<int>(3,5.5)
考题
下列程序段中有错的是()。 Template//A Type//B Func(Type a,b)//C {retum(a>b)?(a):
下列程序段中有错的是( )。Template<class Type> //AType //BFunc(Type a,b) //C{retum(a>b)?(a):(b);} //DA.AB.BC.CD.D
考题
有类定义如下:class Type{public:Type(int i=0);Type operator-(int);friend Type operator+(Type,Type);private:int val;};若有对象定义Type c1;则下列语句序列中,错误的是A.Type(3)+c1;B.c1+Type(3);C.3-c1;D.c1-3;
考题
有如下程序:ncludeiostreamusing namespace std;class Animal{public:virtual char*getType()const{return“Animal”;}virtual char*getVoice()const{return“Voice”;}};class Dog:public Animal{public:char*getType()const{rgturn“Dog”;}char*getVoice()const{retum“Woof”;}};void type(AnimalA){couta.getType();}void speak(AnimalA){couta.getVoice();}int main(){Dog d.type(D);tout“speak”;speak(D);coutendl;return 0;}运行时的输出结果是【 】
考题
有如下函数模板定义:template T func(T x, T y){return x*x*y*y;)在下列对func的调用中
有如下函数模板定义: template <class T> T func(T x, T y){return x*x*y*y;) 在下列对func的调用中,错误的是A.func(3,5);B.func(3.0,5.5);C.func(3,5.5);D.func<int>(3,5.5);
考题
以下程序的运行结果是______。 include include template class TA
以下程序的运行结果是______。include<iostream.h>include<math.h>template<class T>class TAdd//定义类模板TAdd,T为类型{Tx,y;public:TAdd (Ta,Tb) {x=a,y=b;) //构造函数Tadd() { retum x+y;}//成员函数};void main( ){TAdd<int>A (5,6);
考题
补充完整下面的模板定义:templateclass//Type //Type为类型参数class Xtwo{//由两个Type类型的数据成员构成的模板类Type a;Type b;public:Xtwo(Type aa=O,Type bb=O):a(a.A),b(bB){}int Compare(){//比较a和b的大小if(aB)retum 1;else if(a==@B)@return 0;else return-1:f}Type Sum();{return a+b;}//返回a与b的和Type Mult(); //函数声明,返回a和b的乘积};templateclass Type【 】::Mult(){return a*b;}//Mult函数的类外定义
考题
有如下程序:Private type stuX as stringY as integerEnd typePrivate Sub Command1_Click()Dim a as stua.x=”ABCD”a.Y=12345print aEnd Sub程序运行时出现错误,错误的原因是A)Type定义语句没有放在标准模块中B)变量声明语句有错C)赋值语句不对D)输出语句print不对
考题
下列的模板说明中,正确的是( )。A.template B.template C.template
下列的模板说明中,正确的是( )。A.template <T1,T2>B.template <class T1,T2>C.template <class T1,class T2>D.template <typename T1;typename T2>
考题
下列程序段中有错的是()。A.templateB.TypeC.func(Type a,b)D.{return(a>b)?(a):(b);
下列程序段中有错的是( )。A.template<Class Type>B.TypeC.func(Type a,b)D.{return(a>b)?(a):(b);}
考题
下列程序的输出结果是()。 include int b=2; int func(int*A) {b+=*a;retum b;} main(
下列程序的输出结果是( )。#include<stdio.h>int b=2;int func(int*A){ b+=*a;retum b;}main(){ int a=1,t=2;t+=func(A) ;printf("%d\n",t);}A.4B.5C.6D.8
考题
下列对模板的声明中,正确的是A.templateB.templateC.template
下列对模板的声明中,正确的是A.template<T>B.template<class T1,T2>C.template<classT1,class T2>D.template<classT1;class T2>
考题
有如下程序: Private Type stu X As String Y As Integer End Type Private Sub Command1 Click( ) Dim a As stu X="ABCD" Y=12345 Print a End Sub 程序运行时出现错误,错误的原因是( )。A.Type定义语句没有放在标准模块中B.变量声明语句有错C.赋值语句不对D.输出语句Print不对
考题
下面的程序段中,有()处错误。template T2 func(T1 a,b){return(a>b) ?(a) :(b) ;}A.
下面的程序段中,有( )处错误。 template <class T1,T2> T2 func(T1 a,b) { return (a>b) ?(a) :(b) ; }A.1B.2C.3D.4
考题
下列程序段的输出是( ) typedef union{ long x[2]; short y[4][5]; char z[10]; }TYPE1; TYPE1 u1; printf("%d\n", sizeof(u1));A.8B.10C.40D.58
考题
阅读下列程序段,注释指令中属性分离符的功能。 DATA SEGMENT A DW 20,100,-60H B DB ‘ABCDEFG ’ DATA ENDS ┆ ①MOV AX, SEG B ②MOV BX, OFFSET B ③MOV CX, TYPE A ④MOV DX , TYPE B
考题
问答题阅读下列程序段,注释指令中属性分离符的功能。 DATA SEGMENT A DW 20,100,-60H B DB ‘ABCDEFG ’ DATA ENDS ┆ ①MOV AX, SEG B ②MOV BX, OFFSET B ③MOV CX, TYPE A ④MOV DX , TYPE B
热门标签
最新试卷