| |
| |
Preface | |
| |
| |
| |
The Basics | |
| |
| |
| |
What Is C++? | |
| |
| |
A Brief History of C++ | |
| |
| |
C++ Organization | |
| |
| |
How to Learn C++ | |
| |
| |
| |
The Basics of Program Writing | |
| |
| |
Programs from Conception to Execution | |
| |
| |
Creating a Real Program | |
| |
| |
Getting Help in Unix | |
| |
| |
Getting Help in an IDE | |
| |
| |
| |
Style | |
| |
| |
Comments | |
| |
| |
C++ Code | |
| |
| |
Naming Style | |
| |
| |
Coding Religion | |
| |
| |
Indentation and Code Format | |
| |
| |
Clarity | |
| |
| |
Simplicity | |
| |
| |
Consistency and Organization | |
| |
| |
| |
Basic Declarations and Expressions | |
| |
| |
Basic Program Structure | |
| |
| |
Simple Expressions | |
| |
| |
The std::cout Output Object | |
| |
| |
Variables and Storage | |
| |
| |
Variable Declarations | |
| |
| |
Integers | |
| |
| |
Assignment Statements | |
| |
| |
Floating-Point Numbers | |
| |
| |
Floating-Point Divide Versus Integer Divide | |
| |
| |
Characters | |
| |
| |
Wide Characters | |
| |
| |
Boolean Type | |
| |
| |
| |
Arrays, Qualifiers, and Reading Numbers | |
| |
| |
Arrays | |
| |
| |
Strings | |
| |
| |
Reading Data | |
| |
| |
Initializing Variables | |
| |
| |
Multidimensional Arrays | |
| |
| |
C-Style Strings | |
| |
| |
Types of Integers | |
| |
| |
Types of Floats | |
| |
| |
Constant and Reference Declarations | |
| |
| |
Qualifiers | |
| |
| |
Hexadecimal and Octal Constants | |
| |
| |
Operators for Performing Shortcuts | |
| |
| |
Side Effects | |
| |
| |
| |
Decision and Control Statements | |
| |
| |
if Statement | |
| |
| |
else Statement | |
| |
| |
How Not to Use std::strcmp | |
| |
| |
Looping Statements | |
| |
| |
while Statement | |
| |
| |
break Statement | |
| |
| |
continue Statement | |
| |
| |
The Assignment Anywhere Side Effect | |
| |
| |
| |
The Programming Process | |
| |
| |
Setting Up Your Work Area | |
| |
| |
The Specification | |
| |
| |
Code Design | |
| |
| |
The Prototype | |
| |
| |
The Makefile | |
| |
| |
Testing | |
| |
| |
Debugging | |
| |
| |
Maintenance | |
| |
| |
Revisions | |
| |
| |
Electronic Archaeology | |
| |
| |
Mark Up the Program | |
| |
| |
Use the Debugger | |
| |
| |
Use the Text Editor as a Browser | |
| |
| |
Add Comments | |
| |
| |
| |
Simple Programming | |
| |
| |
| |
More Control Statements | |
| |
| |
for Statement | |
| |
| |
switch Statement | |
| |
| |
switch, break, and continue | |
| |
| |
| |
Variable Scope and Functions | |
| |
| |
Scope and Storage Class | |
| |
| |
Namespaces | |
| |
| |
Functions | |
| |
| |
Summary of Parameter Types | |
| |
| |
Recursion | |
| |
| |
Structured Programming Basics | |
| |
| |
Real-World Programming | |
| |
| |
| |
The C++ Preprocessor | |
| |
| |
#define Statement | |
| |
| |
Conditional Compilation | |
| |
| |
#include Files | |
| |
| |
Parameterized Macros | |
| |
| |
Advanced Features | |
| |
| |
| |
Bit Operations | |
| |
| |
Bit Operators | |
| |
| |
The AND Operator (&) | |
| |
| |
Bitwise OR () | |
| |
| |
The Bitwise Exclusive OR ([logical and) | |
| |
| |
The Ones Complement Operator (NOT) | |
| |
| |
The Left and Right Shift Operators ([double left angle bracket], [double right angle bracket]) | |
| |
| |
Setting, Clearing, and Testing Bits | |
| |
| |
Bitmapped Graphics | |
| |
| |
| |
Advanced Types and Classes | |
| |
| |
| |
Advanced Types | |
| |
| |
Structures | |
| |
| |
Unions | |
| |
| |
typedef | |
| |
| |
enum Type | |
| |
| |
Bit Members or Packed Structures | |
| |
| |
Arrays of Structures | |
| |
| |
| |
Simple Classes | |
| |
| |
Stacks | |
| |
| |
Improved Stack | |
| |
| |
Using a Class | |
| |
| |
Introduction to Constructors and Destructors | |
| |
| |
Automatically Generated Member Functions | |
| |
| |
Shortcuts | |
| |
| |
Style | |
| |
| |
Structures Versus Classes | |
| |
| |
| |
More on Classes | |
| |
| |
Friends | |
| |
| |
Constant Functions | |
| |
| |
Constant Members | |
| |
| |
Static Member Variables | |
| |
| |
Static Member Functions | |
| |
| |
The Meaning of static | |
| |
| |
| |
Simple Pointers | |
| |
| |
const Pointers | |
| |
| |
Pointers and Printing | |
| |
| |
Pointers and Arrays | |
| |
| |
The reinterpret_cast | |
| |
| |
Pointers and Structures | |
| |
| |
Command-Line Arguments | |
| |
| |
| |
Advanced Programming Concepts | |
| |
| |
| |
File Input/Output | |
| |
| |
C++ File I/O | |
| |
| |
Conversion Routines | |
| |
| |
Binary and ASCII Files | |
| |
| |
The End-of-Line Puzzle | |
| |
| |
Binary I/O | |
| |
| |
Buffering Problems | |
| |
| |
Unbuffered I/O | |
| |
| |
Designing File Formats | |
| |
| |
C-Style I/O Routines | |
| |
| |
C-Style Conversion Routines | |
| |
| |
C-Style Binary I/O | |
| |
| |
C- Versus C++- Style I/O | |
| |
| |
| |
Debugging and Optimization | |
| |
| |
Code Reviews | |
| |
| |
Serial Debugging | |
| |
| |
Going Through the Output | |
| |
| |
Interactive Debuggers | |
| |
| |
Debugging a Binary Search | |
| |
| |
Interactive Debugging Tips and Tricks | |
| |
| |
Runtime Errors | |
| |
| |
Optimization | |
| |
| |
How to Optimize | |
| |
| |
Case Study: Inline Functions Versus Normal Functions | |
| |
| |
Case Study: Optimizing a Color-Rendering Algorithm | |
| |
| |
| |
Operator Overloading | |
| |
| |
Creating a Simple Fixed-Point Class | |
| |
| |
Operator Functions | |
| |
| |
Operator Member Functions | |
| |
| |
Warts | |
| |
| |
Full Definition of the Fixed-Point Class | |
| |
| |
| |
Floating Point | |
| |
| |
Floating-Point Format | |
| |
| |
Floating Addition/Subtraction | |
| |
| |
Multiplication and Division | |
| |
| |
Overflow and Underflow | |
| |
| |
Roundoff Error | |
| |
| |
Accuracy | |
| |
| |
Minimizing Roundoff Error | |
| |
| |
Determining Accuracy | |
| |
| |
Precision and Speed | |
| |
| |
Power Series | |
| |
| |
| |
Advanced Pointers | |
| |
| |
Pointers, Structures, and Classes | |
| |
| |
delete Operator | |
| |
| |
Linked Lists | |
| |
| |
Ordered Linked Lists | |
| |
| |
Doubly Linked Lists | |
| |
| |
Trees | |
| |
| |
Printing a Tree | |
| |
| |
The Rest of the Program | |
| |
| |
Data Structures for a Chess Program | |
| |
| |
| |
Advanced Classes | |
| |
| |
Derived Classes | |
| |
| |
Virtual Functions | |
| |
| |
Virtual Classes | |
| |
| |
Function Hiding in Derived Classes | |
| |
| |
Constructors and Destructors in Derived Classes | |
| |
| |
The dynamic_cast Operator | |
| |
| |
| |
Other Language Features | |
| |
| |
| |
Exceptions | |
| |
| |
Adding Exceptions to the Stack Class | |
| |
| |
Exceptions Versus assert | |
| |
| |
| |
Modular Programming | |
| |
| |
Modules | |
| |
| |
Public and Private | |
| |
| |
The extern Storage Class | |
| |
| |
Headers | |
| |
| |
The Body of the Module | |
| |
| |
A Program to Use Infinite Arrays | |
| |
| |
The Makefile for Multiple Files | |
| |
| |
Using the Infinite Array | |
| |
| |
Dividing a Task into Modules | |
| |
| |
Module Design Guidelines | |
| |
| |
| |
Templates | |
| |
| |
What Is a Template? | |
| |
| |
Templates: The Hard Way | |
| |
| |
Templates: The C++ Way | |
| |
| |
Function Specialization | |
| |
| |
Class Templates | |
| |
| |
Class Specialization | |
| |
| |
Implementation Details | |
| |
| |
Advanced Features | |
| |
| |
| |
Standard Template Library | |
| |
| |
STL Basics | |
| |
| |
Class List--A Set of Students | |
| |
| |
Creating a Waiting List with the STL List | |
| |
| |
Storing Grades in a STL Map | |
| |
| |
Putting It All Together | |
| |
| |
Practical Considerations When Using the STL | |
| |
| |
Getting More Information | |
| |
| |
| |
Program Design | |
| |
| |
Design Goals | |
| |
| |
Design Factors | |
| |
| |
Design Principles | |
| |
| |
Coding | |
| |
| |
Objects | |
| |
| |
Real-World Design Techniques | |
| |
| |
| |
Putting It All Together | |
| |
| |
Requirements | |
| |
| |
Code Design | |
| |
| |
Coding | |
| |
| |
Functional Description | |
| |
| |
Testing | |
| |
| |
Revisions | |
| |
| |
A Final Warning | |
| |
| |
Program Files | |
| |
| |
| |
From C to C++ | |
| |
| |
K&R-Style Functions | |
| |
| |
struct | |
| |
| |
malloc and free | |
| |
| |
Turning Structures into Classes | |
| |
| |
setjmp and longjmp | |
| |
| |
Mixing C and C++ Code | |
| |
| |
| |
C++'s Dustier Corners | |
| |
| |
do/while | |
| |
| |
goto | |
| |
| |
The?: Construct | |
| |
| |
The Comma Operator | |
| |
| |
Overloading the () Operator | |
| |
| |
Pointers to Members | |
| |
| |
The asm Statement | |
| |
| |
The mutable Qualifier | |
| |
| |
Run Time Type Identification | |
| |
| |
Trigraphs | |
| |
| |
| |
Programming Adages | |
| |
| |
General | |
| |
| |
Design | |
| |
| |
Declarations | |
| |
| |
switch Statement | |
| |
| |
Preprocessor | |
| |
| |
Style | |
| |
| |
Compiling | |
| |
| |
The Ten Commandments for C++ Programmers | |
| |
| |
Final Note | |
| |
| |
| |
Appendixes | |
| |
| |
| |
ASCII Table | |
| |
| |
| |
Ranges | |
| |
| |
| |
Operator Precedence Rules | |
| |
| |
| |
Computing Sine Using a Power Series | |
| |
| |
| |
Resources | |
| |
| |
Index | |