题目内容 (请给出正确答案)
[主观题]

有如下程序: #include <iostream> using namespace std; class Part{ public:

Part(int x=0):val(x) { cout<<val; } ~Part() { cout<<val; } private: int val; }; class Whole { public: Whole(int x, int y, int z=0):p2(x),p1 (y),val(z) { cout<<val; } ~whole() { cout<<val; private: Part p1,p2; int val; }; int main() { Whole obj (1,2,3); return 0; }程序的输出结果是

A.123321

B.213312

C.213

D.123123

提问人:网友ake240 发布时间:2022-01-06
参考答案
查看官方参考答案
如搜索结果不匹配,请 联系老师 获取答案
更多“有如下程序: #include <iostream> usi…”相关的问题
第1题
简要叙述下列程序代码,并判断如下程序的功能: #includ...

简要叙述下列程序代码,并判断如下程序的功能: #include <fstream> #include <iostream> using namespace std; int main(int argc, char* argv[]) { char c; fstream fio(argv[1], ios::in | ios::out); if (fio.fail()) //打开文件成功与否监控 { cerr << "Cannot open file:" << argv[1] << endl; return 1; } while((c=fio.get())!=EOF) //判断是否到达文件末尾 if (isupper(c)) { fio.seekg(-1, ios::cur); fio.put(tolower(c)); } fio.close(); return 0; }

点击查看答案
第2题
有以下程序:#include<iostream.h>#include<iomanip.h>void main(){cout.fill('*');cout.width(10

有以下程序: #include<iostream.h> #include<iomanip.h> void main() { cout.fill('*'); cout.width(10); cout,<setiosflags(ios::left)<<123.45<<endl; } 程序执行后的输出结果是()

A.****123.45

B.**123.45**

C.123.45****

D.***123.45*

点击查看答案
第3题
有以下程序: include<iostream.h> include<fstream.h> include<stdlib.h> intmain() {fstreamfil

有以下程序:

include <iostream.h>

include <fstream.h>

include <stdlib.h>

int main()

{

fstream filel,file2;

char line[100];

filel.open("source.txt",ios::in);

if(!file1)

{

cout<<"Can't open file source.txt!"<<end1;

abort();

}

file2.open("dest.txt",ios::out);

if(!file2)

{

cout<<"Can't open file dest.txt!"<<end1;

abort();

}

while(!file1.eof())

{

filel.getline(1ine,100);

file2<<line;

file2<<end1;

}

filel.close();

file2.close();

return 0;

}

此程序实现的功能是【 】。

点击查看答案
第4题
有以下程序:include<iostream>include<fstream>using namespace std;int main(){fstream file;fi

有以下程序:

include<iostream>

include<fstream>

using namespace std;

int main()

{

fstream file;

file.open("abc.txt", ios :: in);

if (!file )

{

cout<<"Can not open abc.txt"<<end1;

abort();

}

char buf[ 80 ];

int i = 0;

while (!file.eof())

{

file.getline(buf,80);

i++;

}

cout<<"Lines :"<<i<<end1;

file.close();

return 0;

}

程序实现的功能是【 】。

点击查看答案
第5题
对于代码片段: #include ...

对于代码片段: #include <fstream> #include <iostream> using namespace std; int main(){ fstream binaryio; // Create stream object // Read array from the file binaryio.open("array.dat", ios::in | ios::binary); char result[10] = {'\0'}; binaryio.read(reinterpret_cast <char *> (result), 20); cout << result; return 0; } 其中array.dat文件中存放的内容以字节序列表示,各字节的值为 0x30, 0x31, ..., 0x60 执行之后可能出现的状况有:

A、屏幕上没有输出,程序结束,未报告错误

B、屏幕上输出了10个以上字符,程序结束,未报告错误

C、屏幕上输出了10个以上字符,程序出错

D、屏幕上输出了9个字符,然后程序报错

点击查看答案
第6题
以下程序的执行结果是_______。 include<iostream.h> include<fstream.h> include<stdlib.h> void

以下程序的执行结果是_______。

include<iostream.h>

include<fstream.h>

include<stdlib.h>

void main()

{

char ch:

fstream file:

file.open("abc.dat",ios::out1ios::inlios::binary);

if(! file)

{

cout<<“abc.dat文件不能打开”<<endl:

abort

点击查看答案
第7题
使用VC++6.0打开源程序文件3.cpp。其中类TC用于把文件输出到屏幕,然后进行文件的分割。分割的方法
如下:第一个文件的大小是文件的前一半,另外一个文件的大小是剩余部分。此程序将in.txt文件中的内容输出到

屏幕,并且将文件按照以上方式分割,存于文件out1.txt和out2.txt中。

其中定义的类并不完整,按要求完成下列操作,将类的定义补充完整。

(1)从输入文件中获得一个字符,并判断是否到文件结

尾,如果到文件结尾,则退出循环。请在注释1后添加适当的语句。

(2)把获得的输入文件的内容存储到bur中,并且用len

记录下文件的长度。请在注释2后添加适当的语句。

(3)将输入文件的后一半内容存储在第二个文件中,请

在注释3后添加适当的语句。

(4)使用文件流对象打开输入文件in.txt,请在注释4

后添加适当的语句。

注意:增加代码或者修改代码的位置已经用符号表示出来。请不要修改其他的程序代码。

试题程序:

include<iostream.h>

include<fstream.h>

include<stdlib.h)

classTC

{

public:

TC(char*fileName)

{

len=0;

fstreaminfile;

infile.open(fileName,ios::in);

charch;

//********1********

while

{

cout<<ch;

//********2********

}

infile.close;

}

voidsplit

{

fstreamoutfilel;

fstreamoutfile2;

outfile1.open("out1.txt",ios::out);

outfile2.open("out2.txt",ios::out);

inti=0:

for(i=0;i<len/2;i++)

{

outfilel<<buf[i];

}

do

{

//********3********

}

while(i!=len);

outfilel.close;

outfile2.close;

}

prwate:

intlen;

charbuf[1024];

};

voidmain

{

//********4********

TCobj;

obj.split;

return;

}

点击查看答案
第8题
假设文本文件letters.txt中已经存有“1234567890”十个...

假设文本文件letters.txt中已经存有“1234567890”十个字符,则下列程序的运行结果是 。 #include <fstream.h> #include <stdlib.h> void main(void) { fstream file("nums.txt",ios::in); char ch; if (!file) exit(0); file.seekg (1L, ios::beg); file.get(ch); cout << ch << endl; file.seekg (-5L, ios::end); file.get(ch); cout << ch << endl; file.seekg (-2L, ios::cur); file.get(ch); cout << ch << endl; file.close(); }

点击查看答案
第9题
写出下列程序的运行结果【】。include <iostream.h>.include <fstream.h>include <stdlib.h>void ma

写出下列程序的运行结果【 】。

include <iostream.h>.

include <fstream.h>

include <stdlib.h>

void main()

{

fstream outfile, infile;

outfile.open("data.clat", ios:: out);

if(!outfile)

{

cout<<"Can't open the file."<<end1;

abort();

}

outfile<<" 1234567890"<<end1;

outfile<<"aaaaaaaaa"<<end1;

outfile<<"**********"<<end1;

outfile.close();

infile.open("data. dat ", ios:: in);

if(!infile)

{

cout<<"Can't open the file."<<end1;

abort();

}

char line[80];

int I=0;

while(!infile. eof())

{

I++;

infile.getline(line, sizeof(line));

cout<<I<<":"<<line<<end1;

}

infile.close();

}

点击查看答案
第10题
文本文件letters.txt中已经存有“abcdefg”七个字符,则...

文本文件letters.txt中已经存有“abcdefg”七个字符,则下列程序的运行结果是 。 #include <fstream.h> #include <stdlib.h> void main(void) { fstream file("letters.txt",ios::in); char ch; if (!file) exit(0); file.seekg (2L, ios::beg); file.get(ch); cout << ch ; file.seekg (-3L, ios::end); file.get(ch); cout << ch ; file.seekg (1L, ios::cur); file.get(ch); cout << ch << endl; file.close(); }

点击查看答案
第11题
有如下程序: #include #include usingnamespacestd; intmain()(cout$amp;A.***123***456

B.***123456***

C.***123456

D.123456

点击查看答案
账号:
你好,尊敬的用户
复制账号
发送账号至手机
获取验证码
发送
温馨提示
该问题答案仅针对搜题卡用户开放,请点击购买搜题卡。
马上购买搜题卡
我已购买搜题卡, 登录账号 继续查看答案
重置密码
确认修改
欢迎分享答案

为鼓励登录用户提交答案,简答题每个月将会抽取一批参与作答的用户给予奖励,具体奖励活动请关注官方微信公众号:简答题

简答题官方微信公众号

警告:系统检测到您的账号存在安全风险

为了保护您的账号安全,请在“简答题”公众号进行验证,点击“官网服务”-“账号验证”后输入验证码“”完成验证,验证成功后方可继续查看答案!

微信搜一搜
简答题
点击打开微信
警告:系统检测到您的账号存在安全风险
抱歉,您的账号因涉嫌违反简答题购买须知被冻结。您可在“简答题”微信公众号中的“官网服务”-“账号解封申请”申请解封,或联系客服
微信搜一搜
简答题
点击打开微信