| |
| |
Transitioning from C to C++ | |
| |
| |
Introduction | |
| |
| |
C versus C++ | |
| |
| |
How Does the Compiler Recognize a C++ Program? | |
| |
| |
How Does the Preprocesser Know the Environment? | |
| |
| |
A New Style of Commenting | |
| |
| |
Never Assume! (The Implicit Use of Type int) | |
| |
| |
The Default Return Value from main() | |
| |
| |
The Difference between a Declaration and a Definition | |
| |
| |
Formal Argument Names in Function Declarations | |
| |
| |
Formal Argument Names in Function Definitions | |
| |
| |
All Functions Must Be Declared before Being Called | |
| |
| |
The Meaning of Empty Parentheses | |
| |
| |
Default Function Arguments | |
| |
| |
The Difference between Initialization and Assignment (and Why It's Important) | |
| |
| |
Where to Place Your Variable Declarations | |
| |
| |
Variable Declarations inside a for Loop | |
| |
| |
The Tag Name Becomes the Type Name | |
| |
| |
How Enumerated Types in C++ Differ from C | |
| |
| |
Initialization of Global Variables | |
| |
| |
Array Initialization | |
| |
| |
The Boolean Type bool | |
| |
| |
void * Pointers | |
| |
| |
Use 0, Not the Macro NULL | |
| |
| |
The Keyword const | |
| |
| |
New Styles of Casting | |
| |
| |
C and C++ Keywords | |
| |
| |
Namespaces | |
| |
| |
Introduction | |
| |
| |
The Problem | |
| |
| |
How to Create a Namespace | |
| |
| |
The Scope Resolution Operator | |
| |
| |
How to Access Members of a Namespace | |
| |
| |
Be Careful to Avoid Ambiguous Situations | |
| |
| |
Unnamed Namespaces | |
| |
| |
Namespace Aliases | |
| |
| |
The Koenig Lookup Rule | |
| |
| |
Input/Output Basics | |
| |
| |
Introduction | |
| |
| |
Why Switch to Something New? | |
| |
| |
Header File-Naming Conventions | |
| |
| |
The iostream Header File | |
| |
| |
The court Object | |
| |
| |
A Suggestion for Proper Usage of the std Namespace | |
| |
| |
Be Aware of Operator Precedence | |
| |
| |
Formatting the Output | |
| |
| |
The cin Object | |
| |
| |
Checking for End-of-File | |
| |
| |
Reference Variables | |
| |
| |
Introduction | |
| |
| |
What's the Problem? | |
| |
| |
How to Create a Reference Variable | |
| |
| |
All References Must Be Initialized | |
| |
| |
What's the Point of All This Work? | |
| |
| |
const-Qualifying a Reference | |
| |
| |
When Not to Use a Reference | |
| |
| |
There Is No "Constant Reference" | |
| |
| |
Making a Reference to a Pointer | |
| |
| |
Making a Reference to an Array | |
| |
| |
Returning a Reference from a Function | |
| |
| |
Dynamic Memory Allocation | |
| |
| |
Introduction | |
| |
| |
How to Allocate Dynamic Memory for a Single Object | |
| |
| |
How to Initialize a Primitive Type | |
| |
| |
The Meaning of Empty Parentheses | |
| |
| |
How to Release the Free Space for a Single Object | |
| |
| |
How to Allocate Free Space for an Array of Objects | |
| |
| |
How to Release the Free Space for an Array of Objects | |
| |
| |
Keep Things in Balance | |
| |
| |
How to Use new and delete to Store Strings on the Free Store | |
| |
| |
How to Allocate and Delete Multidimensional Arrays | |
| |
| |
Name That Space! | |
| |
| |
Do You Understand? | |
| |
| |
Introduction to Classes | |
| |
| |
Introduction | |
| |
| |
Thinking about Structures in C | |
| |
| |
A First Look at Encapsulation | |
| |
| |
A Structure versus a Class | |
| |
| |
The Purpose of a Class | |
| |
| |
The Components of a Class | |
| |
| |
How to Write a Class Definition | |
| |
| |
Principle of Data Hiding | |
| |
| |
Access Specifiers | |
| |
| |
Modularity and Implementation Hiding | |
| |
| |
How to Access Class Members via Instances | |
| |
| |
Inline Functions | |
| |
| |
mutable Keyword | |
| |
| |
How to Display the Contents of a Class | |
| |
| |
Enumerated Types within Classes | |
| |
| |
Constructors and Destructors | |
| |
| |
Introduction | |
| |
| |
Constructor Definition | |
| |
| |
Destructor Definition | |
| |
| |
How to Instantiate a Class and Invoke the Default Constructor | |
| |
| |
How to Instantiate a Class and Pass Arguments to the Constructor | |
| |
| |
How to Prevent Instantiations with the Default Constructor | |
| |
| |
Implicit Type Conversion | |
| |
| |
Copy Constructor | |
| |
| |
Function Style Cast | |
| |
| |
Initialization versus Assignment | |
| |
| |
Base/Member Initialization List | |
| |
| |
What about Pointers? | |
| |
| |
Formal Argument Names versus Class Member Names | |
| |
| |
Initialization Order of Nonstatic Data Members | |
| |
| |
A Primitive Type Array as a Nonstatic Data Member | |
| |
| |
An Array of User-Defined Types as a Nonstatic Data Member | |
| |
| |
How to Create an Array of User-Defined Instances | |
| |
| |
How to Declare an Array of Constant Data Members | |
| |
| |
How to Create a Single User-Defined Type on the Free Store | |
| |
| |
How to Create an Array of a User-Defined Type on the Free Store | |
| |
| |
Placement Syntax When Calling new | |
| |
| |
More Class Features | |
| |
| |
Introduction | |
| |
| |
The this Pointer | |
| |
| |
Static Class Data Members | |
| |
| |
The Size of a Class | |
| |
| |
Friend Functions | |
| |
| |
Friend Classes | |
| |
| |
Encapsulating a Class | |
| |
| |
Operator Conversion Functions | |
| |
| |
Introduction to Pointers to Class Members | |
| |
| |
Exception Handling | |
| |
| |
Introduction | |
| |
| |
How to Throw an Exception | |
| |
| |
How to Catch an Exception | |
| |
| |
Matching Process for Catch Blocks | |
| |
| |
A Simple Example of Exception Handling | |
| |
| |
Unwinding the Stack | |
| |
| |
What If the Call to new Fails? | |
| |
| |
How to Prevent new from Throwing an Exception | |
| |
| |
Propagating an Exception | |
| |
| |
How to Manage Pointers to the Free Space | |
| |
| |
You Can't Destroy What You Haven't Created | |
| |
| |
Rethrowing an Object | |
| |
| |
Catching Throws from Subobject Members | |
| |
| |
Function-Try-Blocks | |
| |
| |
Mixing Subobject Members and Pointers | |
| |
| |
Partial Construction of an Object | |
| |
| |
Writing Exception-Safe Code | |
| |
| |
Destructors and Exception Handling | |
| |
| |
Exception Specifications | |
| |
| |
Error Conditions | |
| |
| |
How the Compiler Treats Exception Specifications | |
| |
| |
Defining operator new () for a Class | |
| |
| |
Function Overloading | |
| |
| |
Introduction | |
| |
| |
Some Examples of Overloading | |
| |
| |
The Return Type Is Ignored | |
| |
| |
const-Qualifying an Argument Passed by Value | |
| |
| |
const-Qualifying an Argument Passed by Pointer | |
| |
| |
const-Qualifying an Argument Passed by Reference | |
| |
| |
Mutator versus Constant Member Functions | |
| |
| |
Overload Resolution | |
| |
| |
Overloading on a Pointer Type | |
| |
| |
Name Mangling | |
| |
| |
Operator Function Overloading | |
| |
| |
Inheritance | |
| |
| |
Introduction | |
| |
| |
A Derived Class Instance in Memory | |
| |
| |
Using Inheritance to Create an is-a Relationship | |
| |
| |
How to Define a Derived Class | |
| |
| |
A Structure versus a Class (Revisited) | |
| |
| |
The Keyword protected | |
| |
| |
Access Privileges | |
| |
| |
Base Class "Accessor" Functions | |
| |
| |
Changing the Inherited Access | |
| |
| |
Function Hiding | |
| |
| |
How a Derived Class Member Function Calls a Base Class Member Function | |
| |
| |
Manager Functions | |
| |
| |
Introduction to Polymorphism | |
| |
| |
Polymorphism and Virtual Functions | |
| |
| |
Abstract Base Classes | |
| |
| |
Liskov Substitution Principle | |
| |
| |
Multiple Inheritance | |
| |
| |
Templates | |
| |
| |
Introduction | |
| |
| |
Function Templates | |
| |
| |
Class Templates | |
| |
| |
Nontype Template Arguments | |
| |
| |
Member Templates | |
| |
| |
Template Models | |
| |
| |
typename Keyword | |
| |
| |
Runtime Type Information | |
| |
| |
Introduction | |
| |
| |
Dynamic Casting | |
| |
| |
The typeid Keyword | |
| |
| |
Iostream Output | |
| |
| |
Introduction | |
| |
| |
The Instances std::cerr and std::clog | |
| |
| |
How to Format the Output | |
| |
| |
How to Display a bool Type | |
| |
| |
How to Print an Address | |
| |
| |
How to Output to a Memory Buffer | |
| |
| |
Iostream Input | |
| |
| |
Introduction | |
| |
| |
How to Check for Errors | |
| |
| |
Character Input | |
| |
| |
Manipulators | |
| |
| |
Introduction | |
| |
| |
The Format of a Manipulator | |
| |
| |
Some Simple Manipulators | |
| |
| |
Built-In Manipulators Called with No Arguments | |
| |
| |
Manipulators Taking One Argument | |
| |
| |
Built-In Manipulators Taking One Argument | |
| |
| |
File Input/Output | |
| |
| |
Introduction | |
| |
| |
File Input/Output Classes | |
| |
| |
File Output | |
| |
| |
File Input | |
| |
| |
File Position Markers | |
| |
| |
File Update | |
| |
| |
Binary Mode | |
| |
| |
Unformatted Output | |
| |
| |
Unformatted Input | |
| |
| |
Redirecting I/O | |
| |
| |
The string Class and the Standard Template Library | |
| |
| |
Introduction | |
| |
| |
The string Class | |
| |
| |
The Standard Template Library | |
| |
| |
Bibliography | |
| |
| |
C++ Guidelines | |
| |
| |
Index | |