C++ Primer Plus, Fourth Edition
Copyright
PREFACE
Preface to the Fourth Edition
Note to Instructors
How This Book Is Organized
ABOUT THE AUTHOR
ACKNOWLEDGMENTS
TELL US WHAT YOU THINK!
Chapter 1. GETTING STARTED
Learning C++
A Little History
Portability and Standards
The Mechanics of Creating a Program
Conventions Used in This Book
Our System
Chapter 2. SETTING OUT TO C++
C++ Initiation
More About 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 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 the for Loop
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 LOGICALOPERATORS
The if Statement
Logical Expressions
The cctype Library of Character Functions
The ?: Operator
The switch Statement
The break and continue Statements
Number-Reading Loops
Summary
Review Questions
Programming Exercises
Chapter 7. FUNCTIONS桟++'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
Recursion
Pointers to Functions
Summary
Review Questions
Programming Exercises
Chapter 8. ADVENTURES IN FUNCTIONS
Inline Functions
Reference Variables
Default Arguments
Function Polymorphism (Function Overloading)
Function Templates
Summary
Review Questions
Programming Exercises
Chapter 9. MEMORY MODELS AND NAMESPACES
Separate Compilation
Storage Duration, Scope, and Linkage
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
Class Scope
An Abstract Data Type
Summary
Review Questions
Programming Exercises
Chapter 11. WORKING WITH CLASSES
Operator Overloading
Time on Our Hands
Introducing Friends
Overloaded Operators: Member Versus NonmemberFunctions
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
Queue Simulation
Summary
Review Questions
Programming Exercises
Chapter 13. CLASS INHERITANCE
Beginning with a Simple Base Class
Special Relationships
Inheritance桝n <span class=
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 THESTANDARD TEMPLATE LIBRARY
The string Class
The auto_ptr Class
The Standard Template Library
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
Octal Integers
Hexadecimal Numbers
Binary Numbers
Binary and Hex
Appendix B. C++ KEYWORDS
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 So On
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
Appendix I. CONVERTING TO ANSI/ISO STANDARD C++
Preprocessor Directives
Use Function Prototypes
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 REVIEW QUESTIONS
Chapter 2
Chapter 3
Chapter 4
Chapter 5
Chapter 6
Chapter 7
Chapter 8
Chapter 9
Chapter 10
Chapter 11
Chapter 12
Chapter 13
Chapter 14
Chapter 15
Chapter 16
Chapter 17
INDEX