Cover
Copyright
Acknowledgments
About the Author
Contents
Introduction
1 Types, Variables, and Standard I/O: Lost Fortune
Introducing C++
Writing Your First C++ Program
Working with the std Namespace
Using Arithmetic Operators
Declaring and Initializing Variables
Performing Arithmetic Operations with Variables
Working with Constants
Introducing Lost Fortune
Summary
Questions and Answers
Discussion Questions
Exercises
2 Truth, Branching, and the Game Loop: Guess My Number
Understanding Truth
Using the if Statement
Using the else Clause
Using a Sequence of if Statements with else Clauses
Using the switch Statement
Using while Loops
Using do Loops
Using break and continue Statements
Using Logical Operators
Generating Random Numbers
Understanding the Game Loop
Introducing Guess My Number
Summary
Questions and Answers
Discussion Questions
Exercises
3 for Loops, Strings, and Arrays: Word Jumble
Using for Loops
Understanding Objects
Using string Objects
Using Arrays
Understanding C-Style Strings
Using Multidimensional Arrays
Introducing Word Jumble
Summary
Questions and Answers
Discussion Questions
Exercises
4 The Standard Template Library: Hangman
Introducing the Standard Template Library
Using Vectors
Using Iterators
Using Algorithms
Understanding Vector Performance
Examining Other STL Containers
Planning Your Programs
Introducing Hangman
Summary
Questions and Answers
Discussion Questions
Exercises
5 Functions: Mad Lib
Creating Functions
Using Parameters and Return Values
Understanding Software Reuse
Working with Scopes
Using Global Variables
Using Global Constants
Using Default Arguments
Overloading Functions
Inlining Functions
Introducing the Mad Lib Game
Summary
Questions and Answers
Discussion Questions
Exercises
6 References: Tic-Tac-Toe
Using References
Passing References to Alter Arguments
Passing References for Efficiency
Deciding How to Pass Arguments
Returning References
Introducing the Tic-Tac-Toe Game
Summary
Questions and Answers
Discussion Questions
Exercises
7 Pointers: Tic-Tac-Toe 2.0
Understanding Pointer Basics
Understanding Pointers and Constants
Passing Pointers
Returning Pointers
Understanding the Relationship between Pointers and Arrays
Introducing the Tic-Tac-Toe 2.0 Game
Summary
Questions and Answers
Discussion Questions
Exercises
8 Classes: Critter Caretaker
Defining New Types
Using Constructors
Setting Member Access Levels
Using Static Data Members and Member Functions
Introducing the Critter Caretaker Game
Summary
Questions and Answers
Discussion Questions
Exercises
9 Advanced Classes and Dynamic Memory: Game Lobby
Using Aggregation
Using Friend Functions and Operator Overloading
Dynamically Allocating Memory
Working with Data Members and the Heap
Introducing the Game Lobby Program
Summary
Questions and Answers
Discussion Questions
Exercises
10 Inheritance and Polymorphism: Blackjack
Introducing Inheritance
Controlling Access under Inheritance
Calling and Overriding Base Class Member Functions
Using Overloaded Assignment Operators and Copy Constructors in Derived Classes
Introducing Polymorphism
Using Abstract Classes
Introducing the Blackjack Game
Summary
Questions and Answers
Discussion Questions
Exercises
Appendix A Creating Your First C++ Program
Appendix B Operator Precedence
Appendix C Keywords
Appendix D ASCII Chart
Appendix E Escape Sequences
Index