当前位置:高等教育资讯网  >  中国高校课件下载中心  >  大学文库  >  浏览文档

《C++程序设计》(英文版) Chapter 4 Topics

资源类别:文库,文档格式:PPT,文档页数:60,文件大小:3.27MB,团购合买
Chapter 4 Topics o Input Statements to Read Values for a Program using >> and functions get, ignore, getline o Prompting for Interactive Input/Output Noninteractive Input/Output
点击下载完整版文档(PPT)

Programming in c++ Program Input and the Software Design Process Dale/eems/Headington

1 Program Input and the Software Design Process

Programming in C++ Chapter 4 Topics Input Statements to Read Values for a Program using >> and functions get, ignore, getline s Prompting for Interactive Input/Output Noninteractive Input/Output % Using Data Files for Input and Output s Input Failure Software Design Methodologies s Object-Oriented Design Principles Functional Decomposition Methodology

2 Chapter 4 Topics ❖Input Statements to Read Values for a Program using >>, and functions get, ignore, getline ❖Prompting for Interactive Input/Output ❖Noninteractive Input/Output ❖Using Data Files for Input and Output ❖Input Failure ❖Software Design Methodologies ❖Object-Oriented Design Principles ❖Functional Decomposition Methodology

Programming in C++ No l/o is built into C++ s a library provides input stream and output stream Keyboard executing Screen program istream ostream

3 No I/O is built into C++ ❖ a library provides input stream and output stream Keyboard executing Screen program istream ostream

Programming in C++ Keyboard and Screen I/o include input data output data executing Keyboard Screen program cIn cout (of type istream) (of type ostream)

4 Keyboard and Screen I/O #include cin (of type istream) cout (of type ostream) Keyboard Screen executing program input data output data

Programming in C++ is header file &The header file iostream contains the definition of two data types: istream and ostream for a library that defines 3 objects an istream object named cin(keyboard an ostream object named cout(screen) an ostream object named cerr(screen)

5 is header file ❖The header file iostream contains the definition of two data types:istream and ostream ❖for a library that defines 3 objects an istream object named cin (keyboard) an ostream object named cout (screen) an ostream object named cerr (screen)

Programming in C++ Giving a Value to a Variable In your program you can assign(give) a value to the variable by using the assignment operator ageOf。g=12; or by another method, such as cout > ageOf。g;

6 Giving a Value to a Variable In your program you can assign (give) a value to the variable by using the assignment operator = ageOfDog = 12; or by another method, such as cout > ageOfDog;

Programming in C++ Extraction Operator(>> so variable cin is predefined to denote an input stream from the standard input device( the keyboard) s the extraction operator > called get from" takes 2 operands. The left operand is a stream expression, such as cin--the right operand is a variable of simple type %operator > attempts to extract the next item from the input stream and store its value in the right operand variable

7 Extraction Operator ( >> ) ❖ variable cin is predefined to denote an input stream from the standard input device ( the keyboard ) ❖ the extraction operator >> called “get from” takes 2 operands. The left operand is a stream expression, such as cin--the right operand is a variable of simple type. ❖ operator >> attempts to extract the next item from the input stream and store its value in the right operand variable

Programming in C++ Extraction Operator >>(cont “ skips over (actually reads but does not store anywhere) leading white space characters as it reads your data from the input stream(either keyboard or disk file)

8 Extraction Operator >>(cont.) “skips over” (actually reads but does not store anywhere) leading white space characters as it reads your data from the input stream (either keyboard or disk file)

Programming in C++ Extraction Operator(cont) > is a binary operator > is called the input or extraction operator > is left associative EXPRESSION HAS VALUE cIn > age cIn STATEMENT cin > age > weight 9

9 Extraction Operator(cont.) >> is a binary operator >> is called the input or extraction operator >> is left associative EXPRESSION HAS VALUE cin >> age cin STATEMENT cin >> age >> weight ;

Programming in C++ Input Statements SYNTAX cin > Variable>> Variable.; These examples yield the same result cin > length cin > width cin > length > width 10

10 SYNTAX These examples yield the same result. cin >> length ; cin >> width ; cin >> length >> width ; Input Statements cin >> Variable >> Variable . . . ;

点击下载完整版文档(PPT)VIP每日下载上限内不扣除下载券和下载次数;
按次数下载不扣除下载券;
24小时内重复下载只扣除一次;
顺序:VIP每日次数-->可用次数-->下载券;
共60页,可试读20页,点击继续阅读 ↓↓
相关文档

关于我们|帮助中心|下载说明|相关软件|意见反馈|联系我们

Copyright © 2008-现在 cucdc.com 高等教育资讯网 版权所有