《面向对象程序设计Ⅱ》期末复习资料.pdf

《面向对象程序设计Ⅱ》期末复习资料.pdf

  1. 1、本文档共9页,可阅读全部内容。
  2. 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
《面向对象程序设计Ⅱ》期末复习资料 《面向对象程序设计Ⅱ》期末复习资料之六:输入输出流 一、选择题 1.下列流类中可以用于处理文件的是( )。(D) A. ios B. iostream C. strstream D.fstream 2.在下列选项中( )是 istream类的对象。(B) A. cerr B. cin C. clog D. cout 3.read 函数的功能是从输入流中读取( )。(D) A. 一个字符 B. 当前字符 C. 一行字符 D. 指定若干个字节 4.下列选项中,用于清除基数格式位设置以十六进制输出的语句是( )。(B) A. cout setf( ios::dec, ios::basefield ) ; B. cout setf( ios::hex, ios::basefield ) ; C. cout setf( ios::oct, ios::basefield ) ; D. cin setf( ios::hex, ios::basefield ) ; 5.下列格式控制符,既可以用于输入,又可以用于输出的是( )。(A) A. setbase B. setfill C. setprecision D. setw 6.下列串流类,在 strstream.h 中定义的是( )。(B) A. istringstream B. istrstream C. ostringstream D. stringstream 7.包含类 fstream 定义的头文件是( )。Wrong! (A) A. fstream.h B. ofstream.h C. ifstream.h D. iostream.h 8.要求打开文件 D:\file.dat,并能够写入数据,正确的语句是( )。(D) A. ifstream infile( D:\\file.dat, ios::in ) ; B. ifstream infile( D:\\file.dat, ios::out ) ; C. ofstream outfile( D:\\file.dat, ios::in ) ; D. fstream iofile( D:\\file.dat, ios::in | ios::out ) ; 9.设已定义浮点型变量 data,以二进制方式把 data 的值写入输出文件流对象 outfile 中去,正确的语句 是( )。(C) A. outfile.write( ( double * ) data , sizeof( double ) ) ; B. outfile.write( ( double * ) data , data ) ; C. outfile.write( ( char * ) data , sizeof( double ) ) ; D. outfile.write( ( char * ) data , data ) ; 二、阅读下列程序,写出执行结果 1.#include iostream.h void main() { double x = 123.456; cout.width( 10 ); cout.setf( ios :: dec, ios :: basefield ); cout x endl; 《面向对象程序设计Ⅱ》期末复习资料 cout.setf( ios :: left ); cout x endl; cout.width( 15 ); cout.setf( ios::right , ios::left ); cout x endl; cout.setf( ios::showpos ); cout x endl; cout -x endl; cout.setf( ios :: scientific ); cout x endl; } 参考答案

文档评论(0)

小蜗牛 + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档