题目详情
当前位置:首页 > 职业培训考试
题目详情:
发布时间:2023-12-01 03:36:39

[填空题]main函数中发生编译错误的语句是 【12】 。 # include <iostream. h> class A { public: int a; const int b: A( ) :a(10) ,b(20) { void fun( ) const { cout<<"a="<<a<<"/tb="<<b<<end1; } }; void main( ) A obj1; const A * ptr = new A: ptr = &obj1; ptr->a=lO0; ptr->fun( ), }

更多"main函数中发生编译错误的语句是 【12】 。 # i"的相关试题:

[填空题]参照函数模板的写法,完成非模板函数的定义,语句为______。 #include<iostream.h) #include(string.h> template(class T) T min(T a,T b) { return(a<ba:b); } char*min(char*a,char*b) { } void main( ) { double a=1.23,b=3.45; chars1[]=”abcd”,s2[]=”efg”; cout<<min(a,b)<<rain(s1,s2)<(endl; }
[填空题]main函数中发生编译错误的语句是______。 #include<iostream.h> class A { public: int a; const int b; A( ):a(10),b(20){} void fun( )const { cout<<"a="<<a<<"/tb="<<b<<endl; } }; void main( ) { A obj1; const A*ptr=new A; ptr=&obj1; ptr->a=100; ptr->fun( ); }
[填空题]main函数中发生编译错误的语句是______。
#include<iostream.h>
class A

public:
int a;
const int b;
A( ):a(10),b(20)
void fun( )const

cout<<"a="<<a<<"/tb="<<b<<endl;

;
void main( )

A obj1;
const A*ptr=new A;
ptr=&obj1;
ptr->a=100;
ptr->fun( );

[填空题]下列类的构造函数不能通过编译,正确的构造函数应该是______。
#include<iostream.h>
class Sample

public:
int n;
const int con;
Sample(int m) con=m+1;n=m;
void disp( ) cout<<"normal:n="<<n<<endl;
void disp( )const cout<<"static:n="<<n<<endl;
;
void main( )

const Sample a (12);
Sample b (13);
a.disp( );
b.isp( );
cout<<a.n<<","<<b.con<<endl;

[单项选择]要使程序执行后的输出结果为ABCD,应在横线处添加语句( )。
#include<iostream>
using namespace std;

public:A( )cout<<’A’;
;
class B=______

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;
A. public A
B. private A
C. protected A
D. virtual public A
[填空题]下列程序不能通过编译,应该在划线部分填写的语句是______。 #include<iostream.h> #include<stdlib.h> double Func(int a,int b,char ch) { double x; switch(ch) { case’+’: x=double(a)+b; break; case ’-’: x=double(a)-b; break; case ’*’: x=double(a)*b; break; case’/’: if(B)x=double(a)/b; else exit(1); break; default: exit(1); } ______ } void main( ) { cout<<Func(32,6,’-’)<<","; cout<<Func(32,6, ’*’)<<","; cout<<Func(32,6,’/’)<<endl; }
[填空题]设文件temp.txt 已存在,则以下的打印结果是 【15】
#include <iostream>
#include <fstream>
using namespace std;
int main( )

ofstream outf ("temp.txt",ios base: :trunC) ;
outf<<"How you doing";
outf.close( );
ifstream inf("temp.txt");
char str[20];
inf>>str;
inf.close( );
cout<<str;
return 0;

[填空题]下面程序的输出结果为:Base:: fun,请将程序补充完整。 #include <iostream.h> class Base{ public: 【12】 fun( ){cout<<"Base::fun"<<end1:} class Derived : public Base{ public: 【13】 fun( ){ cout<<"Derived::fun"<<end1; } }; int main( ) { Base a,*pb; Derived b; pb = &b; pb->fun( ); return 0; }
[填空题]如下程序编译时发生错误,错误的原因是show函数实现语句错误,则正确的语句应该为 【8】
# include<iostream.h>
class testprivate:
int num;
public:
test(int)
void show( );
;
test: :test(int n) num=n;
test:: show( ) cout<<num<<end1;
void main( ) test T(10);
T. show ( );

[填空题]如下程序编译时发生错误,错误的原因是show函数实现语句错误,则正确的语句应该为______。 #include<iostream.h> class test { private: int hum; public: test(int); void show( ); }; test::test(int n){num=n;} test::show( ){cout<<num<<endl;} void main( ) { test T(10): T.show( ); }
[填空题]类中包含了一个静态成员函数,则main函数中和P. f1 (P); 语句具有同样功能的语句为 【11】 。 #include <iostream. h> class M { public, M(int a) { A=a; B+=a; static void f1(M m) private: int A; static int B: } void M: :f1(M m) { cout<<"A="<<m. A<<endl; cout<<"B="<<m. B<<endl; } int M: :B=10, void main( ) { M P(5); P. f1(P); }
[填空题]下面程序通过调用函数模板实现计算两个正整数的最大公约数,把main函数中的错误找出并改正过来。
#include<iostream.h>
template<class T>
T gcd(T x,T y)
while(x!=y)
if(x>y)x-=y;
else y-=x;

return x;

void main( )
int a;
double d;
cin>>a>>d:
cout<<gcd(a,d)<<endl;

[填空题]请补充fun( )函数,fun函数的功能是求m的阶乘。 请勿改动main( )函数与其他函数中的任何内容,仅在fun( )函数的横线上填写所需的若干表达式语句。 注意:部分源程序给出如下。 试题程序: #include<stdio.h> long fun(int m) { if(______) return(m*fun(______)); return ______; } void main( ) { printf("8!=%ld/n",fun(8)); }

[填空题]参照函数模板的写法,完成非模板函数的定义,语句为 【12】
#include<iostream, h>
#include<string. h>
template<class T>
T min(T a, T b)

return(a<b a:b);

char * min(char * a, char * b)

__________________________

void main( )

double a=1.23,b=3.45;
char s1[]="abcd",s2[]="erg";
cout<<min(a, b)<<min(s1,s2)<<end1:

[填空题]类中包含了一个静态成员函数,则main函数中和P.fl(P);语句具有同样功能的语句为______。 #include<iostream.h> class M { public: M(int A){A=a;B+=a;} static void fl(M m); private: int A; static int B; }; void M::f1(M m) { cout<<"A="<<m.A<<endl; cout<<"B="<<m.B<<endl; } int M::B=10; void main( ) { M P(5); P.f1(P); }

我来回答:

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

订单号:

请不要关闭本页面,支付完成后请点击【支付完成】按钮
恭喜您,购买搜题卡成功
重要提示:请拍照或截图保存账号密码!
我要搜题网官网:https://www.woyaosouti.com
我已记住账号密码