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

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 . . . ;
按次数下载不扣除下载券;
注册用户24小时内重复下载只扣除一次;
顺序:VIP每日次数-->可用次数-->下载券;
- 《C++程序设计》(英文版) Chapter 3 Topics.ppt
- 《C++程序设计》(英文版) Chapter 2 Topics.ppt
- 《C++程序设计》(英文版) Chapter 1 Topics.ppt
- 《网络互连技术教程》第9章 广播.ppt
- 《网络互连技术教程》第8章 用户数据报协议—UDP.ppt
- 《网络互连技术教程》第7章 CMP和网络状态.ppt
- 《网络互连技术教程》第6章 地址解析.ppt
- 《网络互连技术教程》第5章 子网与超网.ppt
- 《网络互连技术教程》第4章 网络互连协议——IP.ppt
- 《网络互连技术教程》第3章 网络接入技术.ppt
- 《网络互连技术教程》第2章 网络互连体系.ppt
- 《网络互连技术教程》第1章 网络的历史与发展.ppt
- 《网络互连技术教程》第12章 应用服务.ppt
- 《网络互连技术教程》第11章 域名服务系统—DNS.ppt
- 《网络互连技术教程》第10章 传输控制协议—7CP.ppt
- 高职高专课程:《数据库应用技术(SQL SERVER2000)》电子教案(PPT教学课件)第9章 存储过程与触发器.ppt
- 高职高专课程:《数据库应用技术(SQL SERVER2000)》电子教案(PPT教学课件)第8章 视图及其应用.ppt
- 高职高专课程:《数据库应用技术(SQL SERVER2000)》电子教案(PPT教学课件)第7章 索引及其应用.ppt
- 高职高专课程:《数据库应用技术(SQL SERVER2000)》电子教案(PPT教学课件)第6章 SQL Server 2000 数据完整性.ppt
- 高职高专课程:《数据库应用技术(SQL SERVER2000)》电子教案(PPT教学课件)第5章 数据的基本操作.ppt
- 《C++程序设计》(英文版) Chapter 5 Topics.ppt
- 《C++程序设计》(英文版) Chapter 6 Topics.ppt
- 《C++程序设计》(英文版) Chapter 7 Topics.ppt
- 《C++程序设计》(英文版) Chapter 8 Topics.ppt
- 《C++程序设计》(英文版) Chapter 9 Topics.ppt
- 《C++程序设计》(英文版) Chapter 10 Topics.ppt
- 《C++程序设计》(英文版) Chapter 11 Topics.ppt
- 《C++程序设计》(英文版) Chapter 12 Topic.ppt
- 《C++程序设计》(英文版) Chapter 13 Topics.ppt
- 《C++程序设计》(英文版) Chapter 14 Topics.ppt
- 《C++程序设计》(英文版) Chapter 15 Topics.ppt
- 《Java编程技术基础》第一章 面向对象原理与实现.ppt
- 《Java编程技术基础》第二章 Java的实现基础.ppt
- 《Java编程技术基础》第二章习题.doc
- 《Java编程技术基础》第三章 类与对象(一).ppt
- 《Java编程技术基础》第三章习题.doc
- 《Java编程技术基础》第四章 类与对象(二).ppt
- 《Java编程技术基础》第四章习题.doc
- 《Java编程技术基础》第五章 异常与垃圾收集.ppt
- 《Java编程技术基础》第五章习题.doc