logo资料库

C++ Primer Plus (5th Edition)(英文原版).pdf

第1页 / 共1225页
第2页 / 共1225页
第3页 / 共1225页
第4页 / 共1225页
第5页 / 共1225页
第6页 / 共1225页
第7页 / 共1225页
第8页 / 共1225页
资料共1225页,剩余部分请下载后查看
C++ Primer Plus, Fifth Edition
Copyright © 2005 by Sams Publishing
CONTENTS AT A GLANCE
TABLE OF CONTENTS
ABOUT THE AUTHOR
WE WANT TO HEAR FROM YOU!
INTRODUCTION
CHAPTER 1 GETTING STARTED
Learning C++: What Lies Before You
The Origins of C++: A Little History
Portability and Standards
The Mechanics of Creating a Program
Summary
CHAPTER 2 SETTING OUT TO C++
C++ Initiation
C++ Statements
More C++ Statements
Functions
Summary
Review Questions
Programming Exercises
CHAPTER 3 DEALING WITH DATA
Simple Variables
The const Qualifier
Floating-Point Numbers
C++ Arithmetic Operators
Summary
Review Questions
Programming Exercises
CHAPTER 4 COMPOUND TYPES
Introducing Arrays
Strings
Introducing the string Class
Introducing Structures
Unions
Enumerations
Pointers and the Free Store
Pointers, Arrays, and Pointer Arithmetic
Summary
Review Questions
Programming Exercises
CHAPTER 5 LOOPS AND RELATIONAL EXPRESSIONS
Introducing for Loops
Relational Expressions
The while Loop
The do while Loop
Loops and Text Input
Nested Loops and Two-Dimensional Arrays
Summary
Review Questions
Programming Exercises
CHAPTER 6 BRANCHING STATEMENTS AND LOGICAL OPERATORS
The if Statement
Logical Expressions
The cctype Library of Character Functions
The ?: Operator
The switch Statement
The break and continue Statements
Number-Reading Loops
Simple File Input/Output
Summary
Review Questions
Programming Exercises
CHAPTER 7 FUNCTIONS: C++’S PROGRAMMING MODULES
Function Review
Function Arguments and Passing by Value
Functions and Arrays
Functions and Two-Dimensional Arrays
Functions and C-Style Strings
Functions and Structures
Functions and string Class Objects
Recursion
Pointers to Functions
Summary
Review Questions
Programming Exercises
CHAPTER 8 ADVENTURES IN FUNCTIONS
C++ Inline Functions
Reference Variables
Default Arguments
Function Overloading
Function Templates
Summary
Review Questions
Programming Exercises
CHAPTER 9 MEMORY MODELS AND NAMESPACES
Separate Compilation
Storage Duration, Scope, and Linkage
The Placement new Operator
Namespaces
Summary
Review Questions
Programming Exercises
CHAPTER 10 OBJECTS AND CLASSES
Procedural and Object-Oriented Programming
Abstraction and Classes
Class Constructors and Destructors
Knowing Your Objects: The this Pointer
An Array of Objects
The Interface and Implementation Revisited
Class Scope
Abstract Data Types
Summary
Review Questions
Programming Exercises
CHAPTER 11 WORKING WITH CLASSES
Operator Overloading
Time on Our Hands: Developing an Operator Overloading Example
Introducing Friends
Overloaded Operators: Member Versus Nonmember Functions
More Overloading: A Vector Class
Automatic Conversions and Type Casts for Classes
Summary
Review Questions
Programming Exercises
CHAPTER 12 CLASSES AND DYNAMIC MEMORY ALLOCATION
Dynamic Memory and Classes
A Queue Simulation
Summary
Review Questions
Programming Exercises
CHAPTER 13 CLASS INHERITANCE
Beginning with a Simple Base Class
Inheritance: An Is-a Relationship
Polymorphic Public Inheritance
Access Control: protected
Abstract Base Classes
Inheritance and Dynamic Memory Allocation
Class Design Review
Summary
Review Questions
Programming Exercises
CHAPTER 14 REUSING CODE IN C++
Classes with Object Members
Private Inheritance
Multiple Inheritance
Class Templates
Summary
Review Questions
Programming Exercises
CHAPTER 15 FRIENDS, EXCEPTIONS, AND MORE
Friends
Nested Classes
Exceptions
RTTI
Type Cast Operators
Summary
Review Questions
Programming Exercises
CHAPTER 16 THE string CLASS AND THE STANDARD TEMPLATE LIBRARY
The string Class
The auto_ptr Class
The STL
Generic Programming
Function Objects (aka Functors)
Algorithms
Other Libraries
Summary
Review Questions
Programming Exercises
CHAPTER 17 INPUT, OUTPUT, AND FILES
An Overview of C++ Input and Output
Output with cout
Input with cin
File Input and Output
Incore Formatting
What Now?
Summary
Review Questions
Programming Exercises
APPENDIX A NUMBER BASES
Decimal Numbers (Base 10)
Octal Integers (Base 8)
Hexadecimal Numbers (Base 16)
Binary Numbers (Base 2)
Binary and Hex
APPENDIX B C++ RESERVED WORDS
C++ Keywords
Alternative Tokens
C++ Library Reserved Names
APPENDIX C THE ASCII CHARACTER SET
APPENDIX D OPERATOR PRECEDENCE
APPENDIX E OTHER OPERATORS
Bitwise Operators
Member Dereferencing Operators
APPENDIX F THE string TEMPLATE CLASS
Thirteen Types and a Constant
Data Information, Constructors, and Odds and Ends
String Access
Basic Assignment
String Searching
Comparison Methods and Functions
String Modifiers
Output and Input
APPENDIX G THE STL METHODS AND FUNCTIONS
Members Common to All Containers
Additional Members for Vectors, Lists, and Deques
Additional Members for Sets and Maps
STL Functions
APPENDIX H SELECTED READINGS AND INTERNET RESOURCES
Selected Readings
Internet Resources
APPENDIX I CONVERTING TO ANSI/ISO STANDARD C++
Use Alternatives for Some Preprocessor Directives
Use Function Prototypes
Use Type Casts
Become Familiar with C++ Features
Use the New Header Organization
Use Namespaces
Use the autoptr Template
Use the string Class
Use the STL
APPENDIX J ANSWERS TO THE REVIEW QUESTIONS
Answers to Review Questions for Chapter 2
Answers to Review Questions for Chapter 3
Answers to Review Questions for Chapter 4
Answers to Review Questions for Chapter 5
Answers to Review Questions for Chapter 6
Answers to Review Questions for Chapter 7
Answers to Review Questions for Chapter 8
Answers to Review Questions for Chapter 9
Answers to Review Questions for Chapter 10
Answers to Review Questions for Chapter 11
Answers to Review Questions for Chapter 12
Answers to Review Questions for Chapter 13
Answers to Review Questions for Chapter 14
Answers to Review Questions for Chapter 15
Answers to Review Questions for Chapter 16
Answers to Review Questions for Chapter 17
INDEX
C++ Primer Plus Fifth Edition Stephen Prata 800 East 96th St., Indianapolis, Indiana, 46240 USA
C++ Primer Plus Copyright © 2005 by Sams Publishing All rights reserved. No part of this book shall be reproduced, stored in a retrieval system, or transmitted by any means, electronic, mechanical, photocopying, recording, or otherwise, without written permission from the publisher. No patent liability is assumed with respect to the use of the information contained herein. Although every precaution has been taken in the preparation of this book, the publisher and author assume no responsibility for errors or omissions. Nor is any liability assumed for damages resulting from the use of the infor- mation contained herein. International Standard Book Number: 0-672-32697-3 Library of Congress Catalog Card Number: 2004095067 Printed in the United States of America First Printing: November, 2004 07 06 05 04 4 3 2 1 Trademarks All terms mentioned in this book that are known to be trademarks or service marks have been appropriately capitalized. Sams Publishing cannot attest to the accuracy of this infor- mation. Use of a term in this book should not be regarded as affecting the validity of any trademark or service mark. Warning and Disclaimer ASSOCIATE PUBLISHER Michael Stephens ACQUISITIONS EDITOR Loretta Yates DEVELOPMENT EDITOR Songlin Qiu MANAGING EDITOR Charlotte Clapp PROJECT EDITOR George E. Nedeff COPY EDITOR Kitty Jarrett INDEXER Erika Millen PROOFREADER Suzanne Thomas TECHNICAL EDITOR David Horvath PUBLISHING COORDINATOR Cindy Teeters MULTIMEDIA DEVELOPER Dan Scherf Every effort has been made to make this book as complete and as accurate as possible, but no warranty or fitness is implied. The information provided is on an “as is” basis. BOOK DESIGNER Gary Adair Bulk Sales Sams Publishing offers excellent discounts on this book when ordered in quantity for bulk purchases or special sales. For more information, please contact U.S. Corporate and Government Sales 1-800-382-3419 corpsales@pearsontechgroup.com For sales outside of the U.S., please contact International Sales 1-317-428-3341 international@pearsontechgroup.com
CONTENTS AT A GLANCE I N T R O D U C T I O N 1 CHAPTER 5 CHAPTER 6 CHAPTER 7 CHAPTER 8 CHAPTER 1 CHAPTER 2 CHAPTER 3 CHAPTER 4 Getting Started . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .11 Setting Out to C++ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .29 Dealing with Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .65 Compound Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .109 Loops and Relational Expressions . . . . . . . . . . . . . . . . . . . . . . . .177 Branching Statements and Logical Operators . . . . . . . . . . . . . . .231 Functions: C++’s Programming Modules . . . . . . . . . . . . . . . . . . .279 Adventures in Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .337 CHAPTER 9 Memory Models and Namespaces . . . . . . . . . . . . . . . . . . . . . . . .393 CHAPTER 10 Objects and Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .445 CHAPTER 11 Working with Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .501 CHAPTER 12 Classes and Dynamic Memory Allocation . . . . . . . . . . . . . . . . . .561 CHAPTER 13 Class Inheritance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .633 CHAPTER 14 Reusing Code in C++ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .701 Friends, Exceptions, and More . . . . . . . . . . . . . . . . . . . . . . . . . .787 The string Class and the Standard Template Library . . . . . . . . .857 CHAPTER 17 Input, Output, and Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .951 APPENDIX A Number Bases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1041 APPENDIX B C++ Reserved Words . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1047 APPENDIX C The ASCII Character Set . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1051 APPENDIX D Operator Precedence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1057 APPENDIX E Other Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1063 APPENDIX F The string Template Class . . . . . . . . . . . . . . . . . . . . . . . . . . . .1075 APPENDIX G The STL Methods and Functions . . . . . . . . . . . . . . . . . . . . . . .1095 CHAPTER 15 CHAPTER 16
APPENDIX H Selected Readings and Internet Resources . . . . . . . . . . . . . . . . .1129 APPENDIX I Converting to ANSI/ISO Standard C++ . . . . . . . . . . . . . . . . . . .1133 Answers to Review Questions . . . . . . . . . . . . . . . . . . . . . . . . . .1141 APPENDIX J I N D E X 1165
TABLE OF CONTENTS INTRODUCTION . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1 CHAPTER 1: Getting Started . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .11 Learning C++: What Lies Before You . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .11 The Origins of C++: A Little History . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .12 The C Language . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .13 C Programming Philosophy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .13 The C++ Shift: Object-Oriented Programming . . . . . . . . . . . . . . . . . . . . . .14 C++ and Generic Programming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .15 The Genesis of C++ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .16 Portability and Standards . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .17 The Mechanics of Creating a Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .19 Creating the Source Code File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .20 Compilation and Linking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .22 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .27 CHAPTER 2: Setting Out to C++ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .29 C++ Initiation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .29 The main() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .31 C++ Comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .34 The C++ Preprocessor and the iostream File . . . . . . . . . . . . . . . . . . . . . . .35 Header Filenames . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .36 Namespaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .37 C++ Output with cout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .38 C++ Source Code Formatting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .41 C++ Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .43 Declaration Statements and Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . .43 Assignment Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .45 A New Trick for cout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .46 More C++ Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .47 Using cin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .47 Concatenating with cout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .48 cin and cout: A Touch of Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .48 Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .50 Using a Function That Has a Return Value . . . . . . . . . . . . . . . . . . . . . . . . .50 Function Variations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .54 User-Defined Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .55 Using a User-Defined Function That Has a Return Value . . . . . . . . . . . . . . .58 Placing the using Directive in Multifunction Programs . . . . . . . . . . . . . . . .60
vi C++ PRIMER PLUS, FIFTH EDITION Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .62 Review Questions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .63 Programming Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .64 CHAPTER 3: Dealing with Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .65 Simple Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .66 Names for Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .66 Integer Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .68 The short, int, and long Integer Types . . . . . . . . . . . . . . . . . . . . . . . . . . .68 Unsigned Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .73 Choosing an Integer Type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .75 Integer Constants . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .76 How C++ Decides What Type a Constant Is . . . . . . . . . . . . . . . . . . . . . . . .78 The char Type: Characters and Small Integers . . . . . . . . . . . . . . . . . . . . . .79 The bool Type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .87 The const Qualifier . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .88 Floating-Point Numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .89 Writing Floating-Point Numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .89 Floating-Point Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .91 Floating-Point Constants . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .93 Advantages and Disadvantages of Floating-Point Numbers . . . . . . . . . . . . .94 C++ Arithmetic Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .95 Order of Operation: Operator Precedence and Associativity . . . . . . . . . . . .96 Division Diversions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .97 The Modulus Operator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .99 Type Conversions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .100 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .105 Review Questions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .106 Programming Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .107 CHAPTER 4: Compound Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .109 Introducing Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .110 Program Notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .112 Initialization Rules for Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .113 Strings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .114 Concatenating String Constants . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .116 Using Strings in an Array . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .116 Adventures in String Input . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .118 Reading String Input a Line at a Time . . . . . . . . . . . . . . . . . . . . . . . . . . . .119 Mixing String and Numeric Input . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .124
CONTENTS vii Introducing the string Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .125 Assignment, Concatenation, and Appending . . . . . . . . . . . . . . . . . . . . . . .126 More string Class Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .127 More on string Class I/O . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .129 Introducing Structures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .131 Using a Structure in a Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .133 Can a Structure Use a string Class Member? . . . . . . . . . . . . . . . . . . . . . .135 Other Structure Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .136 Arrays of Structures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .137 Bit Fields in Structures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .139 Unions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .139 Enumerations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .141 Setting Enumerator Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .142 Value Ranges for Enumerations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .143 Pointers and the Free Store . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .144 Declaring and Initializing Pointers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .147 Pointer Danger . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .149 Pointers and Numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .150 Allocating Memory with new . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .150 Freeing Memory with delete . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .152 Using new to Create Dynamic Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . .153 Pointers, Arrays, and Pointer Arithmetic . . . . . . . . . . . . . . . . . . . . . . . . . . . .156 Program Notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .157 Pointers and Strings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .162 Using new to Create Dynamic Structures . . . . . . . . . . . . . . . . . . . . . . . . . .166 Automatic Storage, Static Storage, and Dynamic Storage . . . . . . . . . . . . . .170 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .172 Review Questions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .173 Programming Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .174 CHAPTER 5: Loops and Relational Expressions . . . . . . . . . . . . . . . . . . . . . . . . .177 Introducing for Loops . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .178 for Loop Parts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .179 Back to the for Loop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .185 Changing the Step Size . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .187 Inside Strings with the for Loop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .188 The Increment (++) and Decrement (--) Operators . . . . . . . . . . . . . . . . . .189 Side Effects and Sequence Points . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .190 Prefixing Versus Postfixing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .191 The Increment/Decrement Operators and Pointers . . . . . . . . . . . . . . . . . .191 Combination Assignment Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . .192
分享到:
收藏