| |
| |
Introduction | |
| |
| |
| |
The Foundation of C++: The C Subset | |
| |
| |
| |
An Overview of C | |
| |
| |
The Origins and History of C | |
| |
| |
C Is a Middle-Level Language | |
| |
| |
C Is a Structured Language | |
| |
| |
C Is a Programmer's Language | |
| |
| |
The Form of a C Program | |
| |
| |
The Library and Linking | |
| |
| |
Separate Compilation | |
| |
| |
Understanding the .C and .CPP File Extensions | |
| |
| |
| |
Expressions | |
| |
| |
The Five Basic Data Types | |
| |
| |
Modifying the Basic Types | |
| |
| |
Identifier Names | |
| |
| |
Variables | |
| |
| |
The const and volatile Qualifiers | |
| |
| |
Storage Class Specifiers | |
| |
| |
Variable Initializations | |
| |
| |
Constants | |
| |
| |
Operators | |
| |
| |
Expressions | |
| |
| |
| |
Statements | |
| |
| |
True and False in C and C++ | |
| |
| |
Selection Statements | |
| |
| |
Iteration Statements | |
| |
| |
Declaring Variables Within Selection and Iteration Statements | |
| |
| |
Jump Statements | |
| |
| |
Expression Statements | |
| |
| |
Block Statements | |
| |
| |
| |
Arrays and Null-Terminated Strings | |
| |
| |
Single-Dimension Arrays | |
| |
| |
Generating a Pointer to an Array | |
| |
| |
Passing Single-Dimension Arrays to Functions | |
| |
| |
Null-Terminated Strings | |
| |
| |
Two-Dimensional Arrays | |
| |
| |
Multidimensional Arrays | |
| |
| |
Indexing Pointers | |
| |
| |
Array Initialization | |
| |
| |
A Tic-Tac-Toe Example | |
| |
| |
| |
Pointers | |
| |
| |
What Are Pointers? | |
| |
| |
Pointer Variables | |
| |
| |
The Pointer Operators | |
| |
| |
Pointer Expressions | |
| |
| |
Pointers and Arrays | |
| |
| |
Multiple Indirection | |
| |
| |
Initializing Pointers | |
| |
| |
Pointers to Functions | |
| |
| |
C's Dynamic Allocation Functions | |
| |
| |
Problems with Pointers | |
| |
| |
| |
Functions | |
| |
| |
The General Form of a Function | |
| |
| |
Scope Rules of Functions | |
| |
| |
Function Arguments | |
| |
| |
argc and argv--Arguments to main() | |
| |
| |
The return Statement | |
| |
| |
Recursion | |
| |
| |
Function Prototypes | |
| |
| |
Declaring Variable-Length Parameter Lists | |
| |
| |
Old-Style Versus Modern FunctionParameter Declarations | |
| |
| |
| |
Structures, Unions, Enumerations, and User-Defined Types | |
| |
| |
Structures | |
| |
| |
Arrays of Structures | |
| |
| |
Passing Structures to Functions | |
| |
| |
Structure Pointers | |
| |
| |
Arrays and Structures Within Structures | |
| |
| |
Bit-Fields | |
| |
| |
Unions | |
| |
| |
Enumerations | |
| |
| |
Using sizeof to Ensure Portability | |
| |
| |
typedef | |
| |
| |
| |
C-Style Console I/O | |
| |
| |
An Important Application Note | |
| |
| |
Reading and Writing Characters | |
| |
| |
Reading and Writing Strings | |
| |
| |
Formatted Console I/O | |
| |
| |
printf() | |
| |
| |
scanf() | |
| |
| |
| |
File I/O | |
| |
| |
C Versus C++ File I/O | |
| |
| |
Streams and Files | |
| |
| |
Streams | |
| |
| |
Files | |
| |
| |
File System Basics | |
| |
| |
fread() and fwrite() | |
| |
| |
fseek() and Random-Access I/O | |
| |
| |
fprintf() and fscanf() | |
| |
| |
The Standard Streams | |
| |
| |
| |
The Preprocessor and Comments | |
| |
| |
The Preprocessor | |
| |
| |
#define | |
| |
| |
#error | |
| |
| |
#include | |
| |
| |
Conditional Compilation Directives | |
| |
| |
#undef | |
| |
| |
Using defined | |
| |
| |
#line | |
| |
| |
#pragma | |
| |
| |
The # and ## Preprocessor Operators | |
| |
| |
Predefined Macro Names | |
| |
| |
Comments | |
| |
| |
Single-Line Comments | |
| |
| |
| |
C++ | |
| |
| |
| |
An Overview of C++ | |
| |
| |
The Origins of C++ | |
| |
| |
What Is Object-Oriented Programming? | |
| |
| |
Some C++ Fundamentals | |
| |
| |
Old-Style vs. Modern C++ | |
| |
| |
Introducing C++ Classes | |
| |
| |
Function Overloading | |
| |
| |
Operator Overloading | |
| |
| |
Inheritance | |
| |
| |
Constructors and Destructors | |
| |
| |
The C++ Keywords | |
| |
| |
The General Form of a C++ Program | |
| |
| |
| |
Classes and Objects | |
| |
| |
Classes | |
| |
| |
Structures and Classes Are Related | |
| |
| |
Unions and Classes Are Related | |
| |
| |
Friend Functions | |
| |
| |
Friend Classes | |
| |
| |
Inline Functions | |
| |
| |
Parameterized Constructors | |
| |
| |
Static Class Members | |
| |
| |
When Constructors and Destructors Are Executed | |
| |
| |
The Scope Resolution Operator | |
| |
| |
Nested Classes | |
| |
| |
Local Classes | |
| |
| |
Passing Objects to Functions | |
| |
| |
Returning Objects | |
| |
| |
Object Assignment | |
| |
| |
| |
Arrays, Pointers, References, and the Dynamic Allocation Operators | |
| |
| |
Arrays of Objects | |
| |
| |
Pointers to Objects | |
| |
| |
Type Checking C++ Pointers | |
| |
| |
The this Pointer | |
| |
| |
Pointers to Derived Types | |
| |
| |
Pointers to Class Members | |
| |
| |
References | |
| |
| |
A Matter of Style | |
| |
| |
C++'s Dynamic Allocation Operators | |
| |
| |
| |
Function Overloading, Copy Constructors, and Default Arguments | |
| |
| |
Function Overloading | |
| |
| |
Overloading Constructors | |
| |
| |
Copy Constructors | |
| |
| |
Finding the Address of an Overloaded Function | |
| |
| |
The overload Anachronism | |
| |
| |
Default Function Arguments | |
| |
| |
Function Overloading and Ambiguity | |
| |
| |
| |
Operator Overloading | |
| |
| |
Creating a Member Operator Function | |
| |
| |
Operator Overloading Using a Friend Function | |
| |
| |
Overloading new and delete | |
| |
| |
Overloading Some Special Operators | |
| |
| |
Overloading the Comma Operator | |
| |
| |
| |
Inheritance | |
| |
| |
Base-Class Access Control | |
| |
| |
Inheritance and protected Members | |
| |
| |
Inheriting Multiple Base Classes | |
| |
| |
Constructors, Destructors, and Inheritance | |
| |
| |
Granting Access | |
| |
| |
Virtual Base Classes | |
| |
| |
| |
Virtual Functions and Polymorphism | |
| |
| |
Virtual Functions | |
| |
| |
The Virtual Attribute Is Inherited | |
| |
| |
Virtual Functions Are Hierarchical | |
| |
| |
Pure Virtual Functions | |
| |
| |
Using Virtual Functions | |
| |
| |
Early vs. Late Binding | |
| |
| |
| |
Templates | |
| |
| |
Generic Functions | |
| |
| |
Applying Generic Functions | |
| |
| |
Generic Classes | |
| |
| |
The typename and export Keywords | |
| |
| |
The Power of Templates | |
| |
| |
| |
Exception Handling | |
| |
| |
Exception Handling Fundamentals | |
| |
| |
Handling Derived-Class Exceptions | |
| |
| |
Exception Handling Options | |
| |
| |
Understanding terminate() and unexpected() | |
| |
| |
The uncaught_exception() Function | |
| |
| |
The exception and bad_exception Classes | |
| |
| |
Applying Exception Handling | |
| |
| |
| |
The C++ I/O System Basics | |
| |
| |
Old vs. Modern C++ I/O | |
| |
| |
C++ Streams | |
| |
| |
The C++ Stream Classes | |
| |
| |
Formatted I/O | |
| |
| |
Overloading [double left angle bracket]and[double right angle bracket] | |
| |
| |
| |
C++ File I/O | |
| |
| |
[left angle bracket]fstream[right angle bracket] and the File Classes | |
| |
| |
Opening and Closing a File | |
| |
| |
Reading and Writing Text Files | |
| |
| |
Unformatted and Binary I/O | |
| |
| |
More get() Functions | |
| |
| |
getline() | |
| |
| |
Detecting EOF | |
| |
| |
The ignore() Function | |
| |
| |
peek() and putback() | |
| |
| |
flush() | |
| |
| |
Random Access | |
| |
| |
I/O Status | |
| |
| |
Customized I/O and Files | |
| |
| |
| |
Run-Time Type ID and the Casting Operators | |
| |
| |
Run-Time Type Identification (RTTI) | |
| |
| |
The Casting Operators | |
| |
| |
dynamic_cast | |
| |
| |
| |
Namespaces, Conversion Functions, and Other Advanced Topics | |
| |
| |
Namespaces | |
| |
| |
The std Namespace | |
| |
| |
Creating Conversion Functions | |
| |
| |
const Member Functions and mutable | |
| |
| |
Volatile Member Functions | |
| |
| |
Explicit Constructors | |
| |
| |
The Member Initialization Syntax | |
| |
| |
Using the asm Keyword | |
| |
| |
Linkage Specification | |
| |
| |
Array-Based I/O | |
| |
| |
Summarizing the Differences Between C and C++ | |
| |
| |
| |
Introducing the Standard Template Library | |
| |
| |
An Overview of the STL | |
| |
| |
The Container Classes | |
| |
| |
General Theory of Operation | |
| |
| |
Vectors | |
| |
| |
Lists | |
| |
| |
Maps | |
| |
| |
Algorithms | |
| |
| |
Using Function Objects | |
| |
| |
The string Class | |
| |
| |
Final Thoughts on the STL | |
| |
| |
| |
The Standard Function Library | |
| |
| |
| |
The C-Based I/O Functions | |
| |
| |
| |
The String and Character Functions | |
| |
| |
| |
The Mathematical Functions | |
| |
| |
| |
Time, Date, and Localization Functions | |
| |
| |
| |
The Dynamic Allocation Functions | |
| |
| |
| |
Utility Functions | |
| |
| |
| |
The Wide-Character Functions | |
| |
| |
The Wide-Character Classification Functions | |
| |
| |
The Wide-Character I/O Functions | |
| |
| |
The Wide-Character String Functions | |
| |
| |
Wide-Character String Conversion Functions | |
| |
| |
Wide-Character Array Functions | |
| |
| |
Multibyte/Wide-Character Conversion Functions | |
| |
| |
| |
The Standard C++ Class Library | |
| |
| |
| |
The Standard C++ I/O Classes | |
| |
| |
The I/O Classes | |
| |
| |
The I/O Headers | |
| |
| |
The Format Flags and I/O Manipulators | |
| |
| |
Several Data Types | |
| |
| |
Overload [double left angle bracket]and[double right angle bracket] Operators | |
| |
| |
The General-Purpose I/O Functions | |
| |
| |
| |
The STL Container Classes | |
| |
| |
The Container Classes | |
| |
| |
| |
The STL Algorithms | |
| |
| |
| |
STL Iterators, Allocators, and Function Objects | |
| |
| |
Iterators | |
| |
| |
Function Objects | |
| |
| |
Allocators | |
| |
| |
| |
The String Class | |
| |
| |
The basic_string Class | |
| |
| |
The char_traits Class | |
| |
| |
| |
The Numeric Classes | |
| |
| |
The complex Class | |
| |
| |
The valarray Class | |
| |
| |
The Numeric Algorithms | |
| |
| |
| |
Exception Handling and Miscellaneous Classes | |
| |
| |
Exceptions | |
| |
| |
auto_ptr | |
| |
| |
The pair Class | |
| |
| |
Localization | |
| |
| |
Other Classes of Interest | |
| |
| |
| |
Applying C++ | |
| |
| |
| |
Integrating New Classes: A Custom String Class | |
| |
| |
The StrType Class | |
| |
| |
The Constructors and Destructors | |
| |
| |
I/O on Strings | |
| |
| |
The Assignment Functions | |
| |
| |
Concatenation | |
| |
| |
Substring Subtraction | |
| |
| |
The Relational Operators | |
| |
| |
Miscellaneous String Functions | |
| |
| |
The Entire StrType Class | |
| |
| |
Using the StrType Class | |
| |
| |
Creating and Integrating New Types in General | |
| |
| |
A Challenge | |
| |
| |
| |
Parsing Expressions | |
| |
| |
Expressions | |
| |
| |
Parsing Expressions: The Problem | |
| |
| |
Parsing an Expression | |
| |
| |
The Parser Class | |
| |
| |
Dissecting an Expression | |
| |
| |
A Simple Expression Parser | |
| |
| |
Adding Variables to the Parser | |
| |
| |
Syntax Checking in a Recursive-Descent Parser | |
| |
| |
Building a Generic Parser | |
| |
| |
Some Things to Try | |
| |
| |
| |
The .NET Managed Extensions to C++ | |
| |
| |
The .NET Keyword Extensions | |
| |
| |
Preprocessor Extensions | |
| |
| |
The attribute Attribute | |
| |
| |
Compiling Managed C++ | |
| |
| |
| |
C++ and the Robotics Age | |
| |
| |
Index | |