|
 |
Copyright |
|
 |
Preface |
|
|
 |
Structure of This Book |
|
|
 |
A Note on the Source Code |
|
|
 |
Acknowledgments |
|
|
 |
Where to Find More Information |
|
|
 |
Typographical Conventions |
|
|
 |
Chapter 1.
Basic C++ Programming |
|
|
 |
Section 1.1.
How to Write a C++ Program |
|
|
 |
Section 1.2.
Defining and Initializing a Data Object |
|
|
 |
Section 1.3.
Writing Expressions |
|
|
 |
Section 1.4.
Writing Conditional and Loop Statements |
|
|
 |
Section 1.5.
How to Use Arrays and Vectors |
|
|
 |
Section 1.6.
Pointers Allow for Flexibility |
|
|
 |
Section 1.7.
Writing and Reading Files |
|
|
 |
Chapter 2.
Procedural Programming |
|
|
 |
Section 2.1.
How to Write a Function |
|
|
 |
Section 2.2.
Invoking a Function |
|
|
 |
Section 2.3.
Providing Default Parameter Values |
|
|
 |
Section 2.4.
Using Local Static Objects |
|
|
 |
Section 2.5.
Declaring a Function Inline |
|
|
 |
Section 2.6.
Providing Overloaded Functions |
|
|
 |
Section 2.7.
Defining and Using Template Functions |
|
|
 |
Section 2.8.
Pointers to Functions Add Flexibility |
|
|
 |
Section 2.9.
Setting Up a Header File |
|
|
 |
Chapter 3.
Generic Programming |
|
|
 |
Section 3.1.
The Arithmetic of Pointers |
|
|
 |
Section 3.2.
Making Sense of Iterators |
|
|
 |
Section 3.3.
Operations Common to All Containers |
|
|
 |
Section 3.4.
Using the Sequential Containers |
|
|
 |
Section 3.5.
Using the Generic Algorithms |
|
|
 |
Section 3.6.
How to Design a Generic Algorithm |
|
|
 |
Section 3.7.
Using a Map |
|
|
 |
Section 3.8.
Using a Set |
|
|
 |
Section 3.9.
How to Use Iterator Inserters |
|
|
 |
Section 3.10.
Using the iostream Iterators |
|
|
 |
Chapter 4.
Object-Based Programming |
|
|
 |
Section 4.1.
How to Implement a Class |
|
|
 |
Section 4.2.
What Are Class Constructors and the Class Destructor? |
|
|
 |
Section 4.3.
What Are mutable and const? |
|
|
 |
Section 4.4.
What Is the this Pointer? |
|
|
 |
Section 4.5.
Static Class Members |
|
|
 |
Section 4.6.
Building an Iterator Class |
|
|
 |
Section 4.7.
Collaboration Sometimes Requires Friendship |
|
|
 |
Section 4.8.
Implementing a Copy Assignment Operator |
|
|
 |
Section 4.9.
Implementing a Function Object |
|
|
 |
Section 4.10.
Providing Class Instances of the iostream Operators |
|
|
 |
Section 4.11.
Pointers to Class Member Functions |
|
|
 |
Chapter 5.
Object-Oriented Programming |
|
|
 |
Section 5.1.
Object-Oriented Programming Concepts |
|
|
 |
Section 5.2.
A Tour of Object-Oriented Programming |
|
|
 |
Section 5.3.
Polymorphism without Inheritance |
|
|
 |
Section 5.4.
Defining an Abstract Base Class |
|
|
 |
Section 5.5.
Defining a Derived Class |
|
|
 |
Section 5.6.
Using an Inheritance Hierarchy |
|
|
 |
Section 5.7.
How Abstract Should a Base Class Be? |
|
|
 |
Section 5.8.
Initialization, Destruction, and Copy |
|
|
 |
Section 5.9.
Defining a Derived Class Virtual Function |
|
|
 |
Section 5.10.
Run-Time Type Identification |
|
|
 |
Chapter 6.
Programming with Templates |
|
|
 |
Section 6.1.
Parameterized Types |
|
|
 |
Section 6.2.
The Template Class Definition |
|
|
 |
Section 6.3.
Handling Template Type Parameters |
|
|
 |
Section 6.4.
Implementing the Template Class |
|
|
 |
Section 6.5.
A Function Template Output Operator |
|
|
 |
Section 6.6.
Constant Expressions and Default Parameters |
|
|
 |
Section 6.7.
Template Parameters as Strategy |
|
|
 |
Section 6.8.
Member Template Functions |
|
|
 |
Chapter 7.
Exception Handling |
|
|
 |
Section 7.1.
Throwing an Exception |
|
|
 |
Section 7.2.
Catching an Exception |
|
|
 |
Section 7.3.
Trying for an Exception |
|
|
 |
Section 7.4.
Local Resource Management |
|
|
 |
Section 7.5.
The Standard Exceptions |
|
|
 |
Appendix A.
Exercise Solutions |
|
|
 |
Exercise 1.4 |
|
|
 |
Exercise 1.5 |
|
|
 |
Exercise 1.6 |
|
|
 |
Exercise 1.7 |
|
|
 |
Exercise 1.8 |
|
|
 |
Exercise 2.1 |
|
|
 |
Exercise 2.2 |
|
|
 |
Exercise 2.3 |
|
|
 |
Exercise 2.4 |
|
|
 |
Exercise 2.5 |
|
|
 |
Exercise 2.6 |
|
|
 |
Exercise 3.1 |
|
|
 |
Exercise 3.2 |
|
|
 |
Exercise 3.3 |
|
|
 |
Exercise 3.4 |
|
|
 |
Exercise 4.1 |
|
|
 |
Exercise 4.2 |
|
|
 |
Exercise 4.3 |
|
|
 |
Exercise 4.4 |
|
|
 |
Exercise 4.5 |
|
|
 |
Exercise 5.1 |
|
|
 |
Exercise 5.2 |
|
|
 |
Exercise 5.3 |
|
|
 |
Exercise 5.4 |
|
|
 |
Exercise 6.1 |
|
|
 |
Exercise 6.2 |
|
|
 |
Exercise 7.1 |
|
|
 |
Section 7.2.
Exercise 7.2 |
|
|
 |
Section 7.3.
Exercise 7.3 |
|
|
 |
Appendix B.
Generic Algorithms Handbook |
|
|
 |
accumulate() |
|
|
 |
adjacent_difference() |
|
|
 |
adjacent_find() |
|
|
 |
binary_search() |
|
|
 |
copy() |
|
|
 |
copy_backward() |
|
|
 |
count() |
|
|
 |
count_if() |
|
|
 |
equal() |
|
|
 |
fill() |
|
|
 |
fill_n() |
|
|
 |
find() |
|
|
 |
find_end() |
|
|
 |
find_first_of() |
|
|
 |
find_if() |
|
|
 |
for_each() |
|
|
 |
generate() |
|
|
 |
generate_n() |
|
|
 |
includes() |
|
|
 |
inner_product() |
|
|
 |
inplace_merge() |
|
|
 |
iter_swap() |
|
|
 |
lexicographical_compare() |
|
|
 |
max(), min() |
|
|
 |
max_element() , min_element() |
|
|
 |
merge() |
|
|
 |
nth_element() |
|
|
 |
partial_sort(), partial_sort_copy() |
|
|
 |
partial_sum() |
|
|
 |
partition(), stable_partition() |
|
|
 |
random_shuffle() |
|
|
 |
remove(), remove_copy() |
|
|
 |
remove_if(), remove_copy_if() |
|
|
 |
replace(), replace_copy() |
|
|
 |
replace_if(), replace_copy_if() |
|
|
 |
reverse(), reverse_copy() |
|
|
 |
rotate(), rotate_copy() |
|
|
 |
search() |
|
|
 |
search_n() |
|
|
 |
set_difference() |
|
|
 |
set_intersection() |
|
|
 |
set_symmetric_difference() |
|
|
 |
set_union() |
|
|
 |
sort(), stable_sort() |
|
|
 |
transform() |
|
|
 |
unique(), unique_copy() |
|
|
 |
Index |