| |
| |
Preface | |
| |
| |
| |
Introduction | |
| |
| |
| |
What is a Computer? | |
| |
| |
| |
What is Programming? | |
| |
| |
| |
The Anatomy of a Computer | |
| |
| |
| |
Translating Human-Readable Programs to Machine Code | |
| |
| |
| |
Programming Languages | |
| |
| |
| |
Programming Language Design and Evolution | |
| |
| |
| |
Becoming Familiar with Your Computer | |
| |
| |
| |
Compiling a Simple Program | |
| |
| |
| |
Errors | |
| |
| |
| |
The Compilation Process | |
| |
| |
| |
Algorithms | |
| |
| |
| |
Fundamental Data Types | |
| |
| |
| |
Number Types | |
| |
| |
| |
Input and Output | |
| |
| |
| |
Assignment | |
| |
| |
| |
Constants | |
| |
| |
| |
Arithmetic | |
| |
| |
| |
Strings | |
| |
| |
| |
Objects | |
| |
| |
| |
Constructing Objects | |
| |
| |
| |
Using Objects | |
| |
| |
| |
Real-Life Objects | |
| |
| |
| |
Displaying Graphical Shapes | |
| |
| |
| |
Graphics Structures | |
| |
| |
| |
Choosing a Coordinate System | |
| |
| |
| |
Getting Input from the Graphics Window | |
| |
| |
| |
Comparing Visual and Numerical Information | |
| |
| |
| |
Basic Control Flow | |
| |
| |
| |
The if Statement | |
| |
| |
| |
The if/else Statement | |
| |
| |
| |
Relational Operators | |
| |
| |
| |
Input Validation | |
| |
| |
| |
Simple Loops | |
| |
| |
| |
Processing a Sequence of Inputs | |
| |
| |
| |
Using Boolean Variables | |
| |
| |
| |
Functions | |
| |
| |
| |
Functions as Black Boxes | |
| |
| |
| |
Writing Functions | |
| |
| |
| |
Function Comments | |
| |
| |
| |
Return Values | |
| |
| |
| |
Parameters | |
| |
| |
| |
Side Effects | |
| |
| |
| |
Procedures | |
| |
| |
| |
Reference Parameters | |
| |
| |
| |
Variable Scope and Global Variables | |
| |
| |
| |
Stepwise Refinement | |
| |
| |
| |
From Pseudocode to Code | |
| |
| |
| |
Walkthroughs | |
| |
| |
| |
Preconditions | |
| |
| |
| |
Classes | |
| |
| |
| |
Discovering Classes | |
| |
| |
| |
Interfaces | |
| |
| |
| |
Encapsulation | |
| |
| |
| |
Member Functions | |
| |
| |
| |
Default Constructors | |
| |
| |
| |
Constructors with Parameters | |
| |
| |
| |
Accessing Data Fields | |
| |
| |
| |
Comparing Member Functions with Nonmember Functions | |
| |
| |
| |
Separate Compilation | |
| |
| |
| |
Advanced Control Flow | |
| |
| |
| |
Multiple Alternatives | |
| |
| |
| |
Nested Branches | |
| |
| |
| |
Boolean Operations | |
| |
| |
| |
De Morgan's Law | |
| |
| |
| |
The for Loop | |
| |
| |
| |
The do Loop | |
| |
| |
| |
Nested Loops | |
| |
| |
| |
Processing Text Input | |
| |
| |
| |
Simulations | |
| |
| |
| |
Testing and Debugging | |
| |
| |
| |
Unit Tests | |
| |
| |
| |
Selecting Test Cases | |
| |
| |
| |
Test Case Evaluation | |
| |
| |
| |
Assertions | |
| |
| |
| |
Program Traces | |
| |
| |
| |
The Debugger | |
| |
| |
| |
Strategies | |
| |
| |
| |
Debugger Limitations | |
| |
| |
| |
Vectors and Arrays | |
| |
| |
| |
Using Vectors to Collect Data Items | |
| |
| |
| |
Vector Subscripts | |
| |
| |
| |
Vector Parameters and Return Values | |
| |
| |
| |
Parallel Vectors | |
| |
| |
| |
Arrays | |
| |
| |
| |
Pointers | |
| |
| |
| |
Pointers and Memory Allocation | |
| |
| |
| |
Deallocating Dynamic Memory | |
| |
| |
| |
Common Uses for Pointers | |
| |
| |
| |
Arrays and Pointers | |
| |
| |
| |
Pointers to Character Strings | |
| |
| |
| |
Inheritance | |
| |
| |
| |
Derived Classes | |
| |
| |
| |
Calling the Base-Class Constructor | |
| |
| |
| |
Calling Base-Class Member Functions | |
| |
| |
| |
Polymorphism | |
| |
| |
| |
Streams | |
| |
| |
| |
Reading and Writing Text Files | |
| |
| |
| |
The Inheritance Hierarchy of Stream Classes | |
| |
| |
| |
String Streams | |
| |
| |
| |
Command Line Arguments | |
| |
| |
| |
Random Access | |
| |
| |
| |
Object-Oriented Design | |
| |
| |
| |
The Software Life Cycle | |
| |
| |
| |
CRC Cards | |
| |
| |
| |
Cohesion | |
| |
| |
| |
Coupling | |
| |
| |
| |
Relationships Between Classes | |
| |
| |
| |
Implementing Associations | |
| |
| |
| |
Case Study: Printing an Invoice | |
| |
| |
| |
Case Study: An Educational Game | |
| |
| |
| |
Recursion | |
| |
| |
| |
Triangle Numbers | |
| |
| |
| |
Permutations | |
| |
| |
| |
Thinking Recursively | |
| |
| |
| |
Recursive Helper Functions | |
| |
| |
| |
Mutual Recursion | |
| |
| |
| |
The Efficiency of Recursion | |
| |
| |
| |
Sorting and Searching | |
| |
| |
| |
Selection Sort | |
| |
| |
| |
Profiling the Selection Sort Algorithm | |
| |
| |
| |
Analyzing the Performance of the Selection Sort Algorithm | |
| |
| |
| |
Merge Sort | |
| |
| |
| |
Analyzing the Merge Sort Algorithm | |
| |
| |
| |
Searching | |
| |
| |
| |
Binary Search | |
| |
| |
| |
Searching and Sorting Real Data | |
| |
| |
| |
An Introduction to Data Structures | |
| |
| |
| |
Linked Lists | |
| |
| |
| |
Implementing Linked Lists | |
| |
| |
| |
Stacks and Queues | |
| |
| |
| |
Other Standard Containers | |
| |
| |
| |
Standard Algorithms | |
| |
| |
| |
Operator Overloading | |
| |
| |
| |
Operator Overloading | |
| |
| |
| |
Case Study: Fractional Numbers | |
| |
| |
| |
Overloading Simple Arithmetic Operators | |
| |
| |
| |
Overloading Comparison Operators | |
| |
| |
| |
Overloading Input and Output | |
| |
| |
| |
Overloading Increment and Decrement Operators | |
| |
| |
| |
Overloading the Assignment Operators | |
| |
| |
| |
Overloading Conversion Operators | |
| |
| |
| |
Overloading the Subscript Operator | |
| |
| |
| |
Overloading the Function Call Operator | |
| |
| |
| |
Case Study: Matrices | |
| |
| |
| |
Memory Management | |
| |
| |
| |
Categories of Memory | |
| |
| |
| |
Common Memory Errors | |
| |
| |
| |
Constructors | |
| |
| |
| |
Destructors | |
| |
| |
| |
Reference Counting | |
| |
| |
| |
Case Study: Matrices, Continued | |
| |
| |
| |
Exception Handling | |
| |
| |
| |
Handling Exceptional Situations | |
| |
| |
| |
Alternative Mechanisms for Handling Exceptions | |
| |
| |
| |
Exceptions | |
| |
| |
| |
Case Study: Matrices, Continued | |
| |
| |
| |
Name Scope Management | |
| |
| |
| |
Encapsulation | |
| |
| |
| |
Name Scopes | |
| |
| |
| |
Protected Scope | |
| |
| |
| |
Friends | |
| |
| |
| |
Nested Classes | |
| |
| |
| |
Private Inheritance and Names | |
| |
| |
| |
Name Spaces | |
| |
| |
| |
CaseStudy: Matrices, Continued | |
| |
| |
| |
Polymorphism | |
| |
| |
| |
Class Inheritance Hierarchies | |
| |
| |
| |
Polymorphic Variables | |
| |
| |
| |
Virtual and Nonvirtual Overriding | |
| |
| |
| |
Pure Virtual Member Functions | |
| |
| |
| |
Obtaining Run-Time Typing Information | |
| |
| |
| |
Slicing and Polymorphism | |
| |
| |
| |
Multiple Inheritance | |
| |
| |
| |
Software Frameworks | |
| |
| |
| |
Templates | |
| |
| |
| |
Template Functions | |
| |
| |
| |
Compile-Time Polymorphism | |
| |
| |
| |
Template Classes | |
| |
| |
| |
Template Linked List | |
| |
| |
| |
Nontype Template Arguments | |
| |
| |
| |
Setting Behavior Using Template Arguments | |
| |
| |
| |
Case Study: Matrices, Continued | |
| |
| |
| |
The Standard Template Library--Containers | |
| |
| |
| |
The STL | |
| |
| |
| |
The Fundamental Containers | |
| |
| |
| |
The Stack and Queue Adapters | |
| |
| |
| |
Sets | |
| |
| |
| |
Maps | |
| |
| |
| |
Case Study: Dijkstra's Shortest Path Algorithm | |
| |
| |
| |
Standard Template Library--Iterators and Algorithms | |
| |
| |
| |
Loose Coupling Produces a Strong Library | |
| |
| |
| |
Iterators | |
| |
| |
| |
Functions, Generators, and Predicates | |
| |
| |
| |
Generic Algorithms | |
| |
| |
| |
Inserters | |
| |
| |
| |
Stream Iterators | |
| |
| |
| |
Standard Function Objects, Predicates, and Binders | |
| |
| |
| |
Case Study: File Merge Sort | |
| |
| |
| |
The Unified Modeling Language | |
| |
| |
| |
Graphical Notations | |
| |
| |
| |
Use Cases | |
| |
| |
| |
UML Class Diagrams | |
| |
| |
| |
Sequence Diagrams | |
| |
| |
| |
State Diagrams | |
| |
| |
| |
Case Study: A Voice Mail System | |
| |
| |
| |
An Introduction to Design Patterns | |
| |
| |
| |
Iterators | |
| |
| |
| |
The Pattern Concept | |
| |
| |
| |
The Adapter Pattern | |
| |
| |
| |
The Template Method Pattern | |
| |
| |
| |
Function Objects and the Strategy Pattern | |
| |
| |
| |
The Composite Pattern | |
| |
| |
| |
Case Study: Putting Patterns to Work | |
| |
| |
| |
Graphical User Interfaces | |
| |
| |
| |
The wxWindows Toolkit | |
| |
| |
| |
Frames | |
| |
| |
| |
Adding a Text Control to the Frame | |
| |
| |
| |
Menus | |
| |
| |
| |
Event Handling | |
| |
| |
| |
Layout Management | |
| |
| |
| |
Painting | |
| |
| |
| |
Mouse Events | |
| |
| |
| |
Dialogs | |
| |
| |
| |
Case Study: A GUI for the Clock Game | |
| |
| |
| |
Relational Databases | |
| |
| |
| |
Organizing Database Information | |
| |
| |
| |
Queries | |
| |
| |
| |
Installing a Database | |
| |
| |
| |
Database Programming in C++ | |
| |
| |
| |
Case Study: Accessing an Invoice Database | |
| |
| |
| |
XML (Web only) | |
| |
| |
| |
XML Tags and Documents | |
| |
| |
| |
Parsing XML Documents | |
| |
| |
| |
Creating XML Documents | |
| |
| |
| |
Document Type Definitions | |
| |
| |
| |
Parsing with Document Type Definitions | |
| |
| |
Appendices | |
| |
| |
| |
C++ Language Coding Guidelines | |
| |
| |
| |
Keyword Summary | |
| |
| |
| |
Operator Summary | |
| |
| |
| |
Character Escape Sequences | |
| |
| |
| |
ASCII Code Table | |
| |
| |
| |
Number Systems | |
| |
| |
| |
Bit and Shift Operations | |
| |
| |
| |
UML Summary | |
| |
| |
| |
A C++/Java Comparison | |
| |
| |
| |
Legacy C++ Features | |
| |
| |
| |
C++ Library Summary | |
| |
| |
Glossary | |
| |
| |
Index | |
| |
| |
Illustration Credits | |