| |
| |
Introduction | |
| |
| |
| |
The Big Picture | |
| |
| |
Why Do We Need Object-Oriented Programming? | |
| |
| |
Characteristics of Object-Oriented Languages | |
| |
| |
C++ and C | |
| |
| |
Laying the Groundwork | |
| |
| |
The Unified Modeling Language (UML) | |
| |
| |
Summary | |
| |
| |
Questions | |
| |
| |
| |
C++ Programming Basics | |
| |
| |
Getting Started | |
| |
| |
Basic Program Construction | |
| |
| |
Output Using cout | |
| |
| |
Directives | |
| |
| |
Comments | |
| |
| |
Integer Variables | |
| |
| |
Character Variables | |
| |
| |
Input with cin | |
| |
| |
Floating Point Types | |
| |
| |
Type bool | |
| |
| |
The setw Manipulator | |
| |
| |
Variable Type Summary | |
| |
| |
Type Conversion | |
| |
| |
Arithmetic Operators | |
| |
| |
Library Functions | |
| |
| |
Summary | |
| |
| |
Questions | |
| |
| |
Exercises | |
| |
| |
| |
Loops and Decisions | |
| |
| |
Relational Operators | |
| |
| |
Loops | |
| |
| |
Decisions | |
| |
| |
Logical Operators | |
| |
| |
Precedence Summary | |
| |
| |
Other Control Statements | |
| |
| |
Summary | |
| |
| |
Questions | |
| |
| |
Exercises | |
| |
| |
| |
Structures | |
| |
| |
Structures | |
| |
| |
Enumerations | |
| |
| |
Summary | |
| |
| |
Questions | |
| |
| |
Exercises | |
| |
| |
| |
Functions | |
| |
| |
Simple Functions | |
| |
| |
Passing Arguments to Functions | |
| |
| |
Returning Values from Functions | |
| |
| |
Reference Arguments | |
| |
| |
Overloaded Functions | |
| |
| |
Recursion | |
| |
| |
Inline Functions | |
| |
| |
Default Arguments | |
| |
| |
Scope and Storage Class | |
| |
| |
Returning by Reference | |
| |
| |
const Function Arguments | |
| |
| |
Summary | |
| |
| |
Questions | |
| |
| |
Exercises | |
| |
| |
| |
Objects and Classes | |
| |
| |
A Simple Class | |
| |
| |
C++ Objects as Physical Objects | |
| |
| |
C++ Objects as Data Types | |
| |
| |
Constructors | |
| |
| |
Objects as Function Arguments | |
| |
| |
The Default Copy Constructor | |
| |
| |
Returning Objects from Functions | |
| |
| |
A Card-Game Example | |
| |
| |
Structures and Classes | |
| |
| |
Classes, Objects, and Memory | |
| |
| |
Static Class Data | |
| |
| |
const and Classes | |
| |
| |
What Does It All Mean? | |
| |
| |
Summary | |
| |
| |
Questions | |
| |
| |
Exercises | |
| |
| |
| |
Arrays and Strings | |
| |
| |
Array Fundamentals | |
| |
| |
Arrays as Class Member Data | |
| |
| |
Arrays of Objects | |
| |
| |
C-Strings | |
| |
| |
The Standard C++ string Class | |
| |
| |
Summary | |
| |
| |
Questions | |
| |
| |
Exercises | |
| |
| |
| |
Operator Overloading | |
| |
| |
Overloading Unary Operators | |
| |
| |
Overloading Binary Operators | |
| |
| |
Data Conversion | |
| |
| |
UML Class Diagrams | |
| |
| |
Pitfalls of Operator Overloading and Conversion | |
| |
| |
Keywords explicit and mutable | |
| |
| |
Summary | |
| |
| |
Questions | |
| |
| |
Exercises | |
| |
| |
| |
Inheritance | |
| |
| |
Derived Class and Base Class | |
| |
| |
Derived Class Constructors | |
| |
| |
Overriding Member Functions | |
| |
| |
Which Function Is Used? | |
| |
| |
Inheritance in the English Distance Class | |
| |
| |
Class Hierarchies | |
| |
| |
Inheritance and Graphics Shapes | |
| |
| |
Public and Private Inheritance | |
| |
| |
Levels of Inheritance | |
| |
| |
Multiple Inheritance | |
| |
| |
private Derivation in Empmult | |
| |
| |
Ambiguity in Multiple Inheritance | |
| |
| |
Aggregation: Classes Within Classes | |
| |
| |
Inheritance and Program Development | |
| |
| |
Summary | |
| |
| |
Questions | |
| |
| |
Exercises | |
| |
| |
| |
Pointers | |
| |
| |
Addresses and Pointers | |
| |
| |
The Address-of Operator and | |
| |
| |
Pointers and Arrays | |
| |
| |
Pointers and Functions | |
| |
| |
Pointers and C-Type Strings | |
| |
| |
Memory Management: new and delete | |
| |
| |
Pointers to Objects | |
| |
| |
A Linked List Example | |
| |
| |
Pointers to Pointers | |
| |
| |
A Parsing Example | |
| |
| |
Simulation: A Horse Race | |
| |
| |
UML State Diagrams | |
| |
| |
Debugging Pointers | |
| |
| |
Summary | |
| |
| |
Questions | |
| |
| |
Exercises | |
| |
| |
| |
Virtual Functions | |
| |
| |
Virtual Functions | |
| |
| |
Friend Functions | |
| |
| |
Static Functions | |
| |
| |
Assignment and Copy Initialization | |
| |
| |
The this Pointer | |
| |
| |
Dynamic Type Information | |
| |
| |
Summary | |
| |
| |
Questions | |
| |
| |
Exercises | |
| |
| |
| |
Streams and Files | |
| |
| |
Stream Classes | |
| |
| |
Stream Errors | |
| |
| |
Disk File I/O with Streams | |
| |
| |
File Pointers | |
| |
| |
Error Handling in File I/O | |
| |
| |
File I/O with Member Functions | |
| |
| |
Overloading the Extraction and Insertion Operators | |
| |
| |
Memory as a Stream Object | |
| |
| |
Command-Line Arguments | |
| |
| |
Printer Output | |
| |
| |
Summary | |
| |
| |
Questions | |
| |
| |
Exercises | |
| |
| |
| |
Multifile Programs | |
| |
| |
Reasons for Multifile Programs | |
| |
| |
Creating a Multifile Program | |
| |
| |
Inter-File Communication | |
| |
| |
A Very Long Number Class | |
| |
| |
A High-Rise Elevator Simulation | |
| |
| |
Summary | |
| |
| |
Questions | |
| |
| |
Projects | |
| |
| |
| |
Templates and Exceptions | |
| |
| |
Function Templates | |
| |
| |
Class Templates | |
| |
| |
Exceptions | |
| |
| |
Summary | |
| |
| |
Questions | |
| |
| |
Exercises | |
| |
| |
| |
The Standard Template Library | |
| |
| |
Introduction to the STL | |
| |
| |
Algorithms | |
| |
| |
Sequence Containers | |
| |
| |
Iterators | |
| |
| |
Specialized Iterators | |
| |
| |
Associative Containers | |
| |
| |
Storing User-Defined Objects | |
| |
| |
Function Objects | |
| |
| |
Summary | |
| |
| |
Questions | |
| |
| |
Exercises | |
| |
| |
| |
Object-Oriented Software Development | |
| |
| |
Evolution of the Software Development Processes | |
| |
| |
Use Case Modeling | |
| |
| |
The Programming Problem | |
| |
| |
The Elaboration Phase for the Landlord Program | |
| |
| |
From Use Cases to Classes | |
| |
| |
Writing the Code | |
| |
| |
Interacting with the Program | |
| |
| |
Final Thoughts | |
| |
| |
Summary | |
| |
| |
Questions | |
| |
| |
Projects | |
| |
| |
| |
ASCII Chart | |
| |
| |
| |
C++ Precedence Table and Keywords | |
| |
| |
Precedence Table | |
| |
| |
Keywords | |
| |
| |
| |
Microsoft Visual C++ | |
| |
| |
Screen Elements | |
| |
| |
Single-File Programs | |
| |
| |
Multifile Programs | |
| |
| |
Building Console Graphics Lite Programs | |
| |
| |
Debugging | |
| |
| |
| |
Borland C++Builder | |
| |
| |
Running the Example Programs in C++Builder | |
| |
| |
Cleaning Up the Screen | |
| |
| |
Creating a New Project | |
| |
| |
Naming and Saving a Project | |
| |
| |
Starting with Existing Files | |
| |
| |
Compiling, Linking, and Executing | |
| |
| |
Adding a Header File to Your Project | |
| |
| |
Projects with Multiple Source Files | |
| |
| |
Console Graphics Lite Programs | |
| |
| |
Debugging | |
| |
| |
| |
Console Graphics Lite | |
| |
| |
Using the Console Graphics Lite Routines | |
| |
| |
The Console Graphics Lite Functions | |
| |
| |
Implementations of the Console Graphics Lite Functions | |
| |
| |
Source Code Listings | |
| |
| |
| |
STL Algorithms and Member Functions | |
| |
| |
Algorithms | |
| |
| |
Member Functions | |
| |
| |
Iterators | |
| |
| |
| |
Answers to Questions and Exercises | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
Bibliography | |
| |
| |
Advanced C++ | |
| |
| |
Defining Documents | |
| |
| |
The Unified Modeling Language | |
| |
| |
The History of C++ | |
| |
| |
Other Topics | |
| |
| |
Index | |