| |
| |
Introduction | |
| |
| |
| |
What Is C++? | |
| |
| |
Why C++ Is the Right Choice | |
| |
| |
Preparing to Program | |
| |
| |
C++, ANSI C++, Windows, and Other Areas of Confusion | |
| |
| |
Your Compiler and Editor | |
| |
| |
The Development Cycle | |
| |
| |
HELLO.CPP--Your First C++ Program | |
| |
| |
Compile Errors | |
| |
| |
| |
What is a C++ Program? | |
| |
| |
The Parts of a Simple Program | |
| |
| |
Comments | |
| |
| |
Functions | |
| |
| |
| |
Variables | |
| |
| |
What Is a Variable? | |
| |
| |
Defining a Variable | |
| |
| |
Creating More Than One Variable at a Time | |
| |
| |
Assigning Values to Your Variables | |
| |
| |
Constants | |
| |
| |
| |
Statements | |
| |
| |
Statements | |
| |
| |
Expressions | |
| |
| |
Operators | |
| |
| |
Combining the Assignment and Mathematical Operators | |
| |
| |
Increment and Decrement | |
| |
| |
Precedence | |
| |
| |
Nesting Parentheses | |
| |
| |
The Nature of Truth | |
| |
| |
Relational Operators | |
| |
| |
| |
The if Statement | |
| |
| |
The if Statement | |
| |
| |
Use Braces in Nested if Statements | |
| |
| |
Logical Operators | |
| |
| |
| |
Functions | |
| |
| |
What Is a Function? | |
| |
| |
Declaring and Defining Functions | |
| |
| |
Local Variables | |
| |
| |
Function Statements | |
| |
| |
Function Arguments | |
| |
| |
Parameters Are Local Variables | |
| |
| |
Return Values | |
| |
| |
Default Parameters | |
| |
| |
Overloading Functions | |
| |
| |
| |
Classes | |
| |
| |
Creating New Types | |
| |
| |
Classes and Members | |
| |
| |
Accessing Class Members | |
| |
| |
Private Versus Public | |
| |
| |
Implementing Class Methods | |
| |
| |
| |
More about Classes | |
| |
| |
Constructors and Destructors | |
| |
| |
const Member Function | |
| |
| |
| |
Using Classes Well | |
| |
| |
Interface Versus Implementation | |
| |
| |
Where to Put Class Declarations and Method Definitions | |
| |
| |
Inline Implementation | |
| |
| |
Classes with Other Classes as Member Data | |
| |
| |
| |
Looping | |
| |
| |
Looping | |
| |
| |
while Loops | |
| |
| |
do...while Loops | |
| |
| |
for Loops | |
| |
| |
| |
Switch Statements | |
| |
| |
Switch Statements | |
| |
| |
| |
Pointers | |
| |
| |
What Is a Pointer? | |
| |
| |
Why Would You Use Pointers? | |
| |
| |
The Stack and the Free Store | |
| |
| |
| |
More About Pointers | |
| |
| |
Creating Objects on the Free Store | |
| |
| |
Deleting Objects | |
| |
| |
Accessing Data Members | |
| |
| |
Member Data on the Free Store | |
| |
| |
The this Pointer | |
| |
| |
What's the this Pointer For? | |
| |
| |
Stray or Dangling Pointers | |
| |
| |
const Pointers | |
| |
| |
| |
References | |
| |
| |
What Is a Reference? | |
| |
| |
Creating a Reference | |
| |
| |
What Can Be Referenced? | |
| |
| |
Null Pointers and Null References | |
| |
| |
Passing Function Arguments by Reference | |
| |
| |
Returning Multiple Values | |
| |
| |
| |
Advanced References and Pointers | |
| |
| |
Passing by Reference for Efficiency | |
| |
| |
References as an Alternative | |
| |
| |
When to Use References and When to Use Pointers | |
| |
| |
Don't Return a Reference to an Object That Isn't in Scope! | |
| |
| |
Returning a Reference to an Object on the Heap | |
| |
| |
Pointer, Pointer, Who Has the Pointer? | |
| |
| |
| |
Advanced Functions | |
| |
| |
Overloaded Member Functions | |
| |
| |
Choosing Between Default Values and Overloaded Functions | |
| |
| |
The Default Constructor | |
| |
| |
Overloading Constructors | |
| |
| |
Initializing Objects | |
| |
| |
The Copy Constructor | |
| |
| |
| |
Operator Overloading | |
| |
| |
Operator Overloading | |
| |
| |
| |
Advanced Operator Overloading | |
| |
| |
Conversion Operators | |
| |
| |
| |
Arrays | |
| |
| |
What Is an Array? | |
| |
| |
Array Elements | |
| |
| |
Writing Past the End of an Array | |
| |
| |
Fence Post Errors | |
| |
| |
Initializing Arrays | |
| |
| |
Arrays of Objects | |
| |
| |
Arrays of Pointers | |
| |
| |
Declaring Arrays on the Free Store | |
| |
| |
A Pointer to an Array Versus an Array of Pointers | |
| |
| |
Pointers and Array Names | |
| |
| |
Deleting Arrays on the Free Store | |
| |
| |
| |
Character Arrays | |
| |
| |
char Arrays | |
| |
| |
strcpy() and strncpy() | |
| |
| |
String Classes | |
| |
| |
| |
Inheritance | |
| |
| |
What Is Inheritance? | |
| |
| |
Private Versus Protected Members | |
| |
| |
| |
Issues in Inheritance | |
| |
| |
Constructors and Destructors | |
| |
| |
Overriding Functions | |
| |
| |
| |
Polymorphism | |
| |
| |
Virtual Methods | |
| |
| |
| |
Advanced Polymorphism | |
| |
| |
Abstract Data Types | |
| |
| |
| |
Linked Lists | |
| |
| |
Linked Lists and Other Structures | |
| |
| |
A Case Study | |
| |
| |
The Component Parts | |
| |
| |
What Have You Learned, Dorothy? | |
| |
| |
| |
Templates | |
| |
| |
What Are Templates? | |
| |
| |
Parameterized Types | |
| |
| |
Template Definition | |
| |
| |
The Standard Template Library | |
| |
| |
| |
Exceptions and Error Handling | |
| |
| |
Handling the Unexpected | |
| |
| |
Exceptions | |
| |
| |
Using try Blocks and catch Blocks | |
| |
| |
| |
Next Steps | |
| |
| |
Where to Get Help and Advice | |
| |
| |
| |
Operator Precedence | |
| |
| |
Index | |