题目详情
当前位置:首页 > 职业培训考试
题目详情:
发布时间:2024-03-07 21:18:24

[填空题]下列程序编译错误,是由于划线处缺少某个语句,该语句是______。
#include<iostream.h>
class A

private:
int numl;
public:
A( ):numl(0)
A(int i):numl(i)
;
class B

private:
int num2;
public:
B( ):num2(0)
B(int i):num2(i)
int my_math(A obj1, B obj2);
;
int B::my_math(A obj1,B obj2)

return(obj1.numl+obj2.num2);

void main(void)

A objl(4);
B obj,obj2(5);
cout<<"obj1+obj2:"<<obj.my_math(obj1,obj2);

更多"下列程序编译错误,是由于划线处缺少某个语句,该语句是______。 "的相关试题:

[填空题]下列程序编译错误,是由于划线处缺少某个语句,该语句是 【15】
#include <iostream. h>
class A

______
private:
int numl;
public:
A( ):numl(0)
A(int i):numl(i)
;
class B

private:
int num2
public:
B( ):num2(0)
B(int i):num2(i)
int my_math(A obj1,B obj2);
;
int B::my_math(A obj1,B obj2)

return (obj1.num1+obj2.num2);

void main(void)

A obj1 (4)
B obj,obi2(5);
cout <<"obj1+obj2:"<<obj.my_math(obj1,obj2);

[填空题]下列程序编译错误,是由于划线处缺少某个语句,该语句是______。 #include<iostream.h> class A { private: int numl; public: A( ):numl(0){} A(int i):numl(i){} }; class B { private: int num2; public: B( ):num2(0){} B(int i):num2(i){} int my_math(A obj1, B obj2); }; int B::my_math(A obj1,B obj2) { return(obj1.numl+obj2.num2); } void main(void) { A objl(4); B obj,obj2(5); cout<<"obj1+obj2:"<<obj.my_math(obj1,obj2); }
[填空题]下列程序中需要清理动态分配的数组,划线处应有的语句是 【13】 。 #include<iostream, h> class person { int age, tall; public: person( ) { age= 0; tall= 40; cout<<"A baby is born. "<<end1;} person(int i) {age=i, tall=40, cout<<"A old person. "<<end1;} person(int i, int i) { age = i; tall = j; cout <<" a old person with tall. "<< end1;} ~person( ) {cout<<" person dead. "<<end 1;} void show( ) { cout<<"age= "<<age<<" ,tall= "<<tall<<end1; } }; void main( ) { person * ptr; ptr = new person[3]; ptr[0]=person ( ) ptr[1]=person(18); ptr[2]=person(20,120); for(int i=0;i<3; i++) ptr[i]. show( ); ______ }
[填空题][说明]
下而程序实现十进制向其他进制的转换。
[C++程序]
#include"ioStream.h"
#include"math.h"
#include <conio.h>
typedef struct node
int data;
node *next;
Node;
class Transform

public:
void Trans(int d,int i); //d为数字;i为进制
void print( );
private:
Node *top;

void Transform::Trans(int d,int i)

int m,n=0;
Node *P;
while(d>0)

(1) ;
d=d/i;
p=new Node;
if(!n)
P->data=m;
(2) j
(3) ;
n++;

else
p->data=m;
(4)
(5)



void Transform::print( )

Node *P;
while(top!=NULL)

p=top;
if(P->data>9)
cout<<data+55:
else
cout<<data;
top=p->next;
delete P;


[填空题]在下面程序的横线处填上适当的内容,使程序执行后的输出结果为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;
[填空题]在下面的程序的横线处填上适当的语句,使该程序的输出结果为12。
#include<iostream>
using namespace std;
class TestClass

public:
int a,b;
TestClass(int i,int j)

a=i;
b=j;

;
class TestClass1:public TestClass

int a;
public:
TestClass1(int x):TestClass(x,x+1)
void show( )

______;∥输出基类数据成员a的值
cout<<b<<endl;

;
int main( )

TestClass1 d(1);
d.show( );
return 0;

[填空题]以下程序设计功能是:将结构体变量time 中的内容写到文件中。
#include <iostream>
using namespace std;
struct date

int year;
int month;
int day;

int main ( )

date time = 2005, 1, 1 ;
ofstream outdate;
outdate.open( "d://date.txt", ios :: binary );
outdate.write(____________, sizeof( tt ) );
outdate.close( );
return 0;

则程序中空白处应该填入的语句为 【15】
[填空题]已知下列程序的输出结果是42,请将横线处缺失的部分补充完整。 #include<iostream> using namespace std; class Foo{ int value; public: Foo( ):value(0){} void setValue(int value) {______=value; ∥给Foo的数据成员value赋值} void print( ){cout<<value;p} }; int main( ) { Foo f; gf.setValue(42); f.print( ); return 0; }
[填空题]下列程序用于将源文件中的字母进行大小写转换,请填写while语句。
#include<iostream.h>
#include<fstream.h>
#include<iomanip.h>
void main( )

char ch;
fstream file1,file2;
char fn1[10],fn2[10];
cout<<"输入源文件名:";
cin>>fn1;
cout<<"输入目标文件名:";
cin>>fn2;
file1.open(fn1,ios::in);
while(______)

if(ch>=’a’&&ch<=’z’)
ch=ch=’a’+’A’;
file2.put(ch);

file1.close( );
file2.close( );

[填空题]下列程序的输出结果为012,请根据注释将横线处的缺失部分补充完整。
#include<iostream>
using namespace std;
class Test
public:
Test(int A) data=a;
~Test( )
void print( )cout<<data;)
private:
int data;
;
int main( )
Test t[3]=______;//对有3个元素的Test类对象数组t初始化
for(int i=0; i<3; i++) t[i]. print( );
return 0;

[填空题]已知下列程序的输出结果是42,请将下画线处缺失的部分补充完整。
#include <iostream>
using namespace std;
class Foo
int value;
public:
Foo( ):value(0)
void setValue(int value)
______=value;//给Foo的数据成员value赋值
void print( )eout<<value;

int main( )
Foo f;
f.setValue(42);
f.print( );
return 0;

[填空题]设文件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; }
[填空题]下列程序编译错误,因为add函数返回值是一个引用,故对return后返回值的要求是 【10】
#include<iostream. h>
int& add(int x, int y)

return x+y;

void main( )
int i=3,j=19;
cout<<(add(i,j)+ =20)<<end1;

[填空题]下列程序编译错误,因为add函数返回值是一个引用,故对return返回值的要求是______。
#include<iostream.h>
int& add(int x,int y)

return x+y;

void main( ) int i=3,j=19;
cout<<(add(i,j)+=20)<<endl;

[填空题]下列程序编译错误,因为add函数返回值是一个引用,故对return后返回值的要求是______。
#include<iostream. h>
int& add(int x, int y)

return x+y;

void main( )
int i=3,j=19;
cout<<(add(i,j)+ =20)<<end1;

我来回答:

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

订单号:

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