| |
| |
Preface | |
| |
| |
| |
Introduction to Computers, the Internet and the World Wide Web | |
| |
| |
| |
Introduction | |
| |
| |
| |
What Is a Computer? | |
| |
| |
| |
Computer Organization | |
| |
| |
| |
Evolution of Operating Systems | |
| |
| |
| |
Personal Computing, Distributed Computing and Client/Server Computing | |
| |
| |
| |
Machine Languages, Assembly Languages and High-level Languages | |
| |
| |
| |
The History of C | |
| |
| |
| |
The C Standard Library | |
| |
| |
| |
The Key Software Trend: Object Technology | |
| |
| |
| |
C++ and C++ How to Program | |
| |
| |
| |
Java and Java How to Program | |
| |
| |
| |
Other High-level Languages | |
| |
| |
| |
Structured Programming | |
| |
| |
| |
The Basics of a typical C Program Development Environment | |
| |
| |
| |
Hardware Trends | |
| |
| |
| |
History of the Internet | |
| |
| |
| |
History of the World Wide Web | |
| |
| |
| |
General Notes About C and this Book | |
| |
| |
| |
Introduction to C Programming | |
| |
| |
| |
Introduction | |
| |
| |
| |
A Simple C Program: Printing a Line of Text | |
| |
| |
| |
Another Simple C Program: Adding Two Integers | |
| |
| |
| |
Memory Concepts | |
| |
| |
| |
Arithmetic in C | |
| |
| |
| |
Decision Making: Equality and Relational Operators | |
| |
| |
| |
Structured Program Development in C | |
| |
| |
| |
Introduction | |
| |
| |
| |
Algorithms | |
| |
| |
| |
Pseudocode | |
| |
| |
| |
Control Structures | |
| |
| |
| |
The if Selection Structure | |
| |
| |
| |
The if/else Selection Structure | |
| |
| |
| |
The while Repetition Structure | |
| |
| |
| |
Formulating Algorithms: Case Study 1 (Counter-Controlled Repetition) | |
| |
| |
| |
Formulating Algorithms with Top-down, Stepwise Refinement: Case Study 2 (Sentinel-Controlled Repetition) | |
| |
| |
| |
Formulating Algorithms with Top-down, Stepwise Refinement: Case Study 3 (Nested Control Structures) | |
| |
| |
| |
Assignment Operators | |
| |
| |
| |
Increment and Decrement Operators | |
| |
| |
| |
C Program Control | |
| |
| |
| |
Introduction | |
| |
| |
| |
The Essentials of Repetition | |
| |
| |
| |
Counter-Controlled Repetition | |
| |
| |
| |
The for Repetition Structure | |
| |
| |
| |
The for Structure: Notes and Observations | |
| |
| |
| |
Examples Using the for Structure | |
| |
| |
| |
The switch Multiple-Selection Structure | |
| |
| |
| |
The do/while Repetition Structure | |
| |
| |
| |
The break and continue Statements | |
| |
| |
| |
Logical Operators | |
| |
| |
| |
Confusing Equality (==) and Assignment (=) Operators | |
| |
| |
| |
Structured Programming Summary | |
| |
| |
| |
C Functions | |
| |
| |
| |
Introduction | |
| |
| |
| |
Program Modules in C | |
| |
| |
| |
Math Library Functions | |
| |
| |
| |
Functions | |
| |
| |
| |
Function Definitions | |
| |
| |
| |
Function Prototypes | |
| |
| |
| |
Header Files | |
| |
| |
| |
Calling Functions: Call by Value and Call by Reference | |
| |
| |
| |
Random Number Generation | |
| |
| |
| |
Example: A Game of Chance | |
| |
| |
| |
Storage Classes | |
| |
| |
| |
Scope Rules | |
| |
| |
| |
Recursion | |
| |
| |
| |
Example Using Recursion: The Fibonacci Series | |
| |
| |
| |
Recursion vs. Iteration | |
| |
| |
| |
C Arrays | |
| |
| |
| |
Introduction | |
| |
| |
| |
Arrays | |
| |
| |
| |
Declaring Arrays | |
| |
| |
| |
Examples Using Arrays | |
| |
| |
| |
Passing Arrays to Functions | |
| |
| |
| |
Sorting Arrays | |
| |
| |
| |
Case Study: Computing Mean, Median and Mode Using Arrays | |
| |
| |
| |
Searching Arrays | |
| |
| |
| |
Multiple-Subscripted Arrays | |
| |
| |
| |
C Pointers | |
| |
| |
| |
Introduction | |
| |
| |
| |
Pointer Variable Declarations and Initialization | |
| |
| |
| |
Pointer Operators | |
| |
| |
| |
Calling Functions by Reference | |
| |
| |
| |
Using the const Qualifier with Pointers | |
| |
| |
| |
Bubble Sort Using Call by Reference | |
| |
| |
| |
Pointer Expressions and Pointer Arithmetic | |
| |
| |
| |
The Relationship between Pointers and Arrays | |
| |
| |
| |
Arrays of Pointers | |
| |
| |
| |
Case Study: A Card Shuffling and Dealing Simulation | |
| |
| |
| |
Pointers to Functions | |
| |
| |
| |
C Characters and Strings | |
| |
| |
| |
Introduction | |
| |
| |
| |
Fundamentals of Strings and Characters | |
| |
| |
| |
Character Handling Library | |
| |
| |
| |
String Conversion Functions | |
| |
| |
| |
Standard Input/Output Library Functions | |
| |
| |
| |
String Manipulation Functions of the String Handling Library | |
| |
| |
| |
Comparison Functions of the String Handling Library | |
| |
| |
| |
Search Functions of the String Handling Library | |
| |
| |
| |
Memory Functions of the String Handling Library | |
| |
| |
| |
Other Functions of the String Handling Library | |
| |
| |
| |
C Formatted Input/Output | |
| |
| |
| |
Introduction | |
| |
| |
| |
Streams | |
| |
| |
| |
Formatting Output with printf | |
| |
| |
| |
Printing Integers | |
| |
| |
| |
Printing Floating-Point Numbers | |
| |
| |
| |
Printing Strings and Characters | |
| |
| |
| |
Other Conversion Specifiers | |
| |
| |
| |
Printing with Field Widths and Precisions | |
| |
| |
| |
Using Flags in the printf Format-Control String | |
| |
| |
| |
Printing Literals and Escape Sequences | |
| |
| |
| |
Formatting Input with scanf | |
| |
| |
| |
C Structures, Unions, Bit Manipulations and Enumerations | |
| |
| |
| |
Introduction | |
| |
| |
| |
Structure Definitions | |
| |
| |
| |
Initializing Structures | |
| |
| |
| |
Accessing Members of Structures | |
| |
| |
| |
Using Structures with Functions | |
| |
| |
| |
typedef | |
| |
| |
| |
Example: High-Performance Card Shuffling and Dealing Simulation | |
| |
| |
| |
Unions | |
| |
| |
| |
Bitwise Operators | |
| |
| |
| |
Bit Fields | |
| |
| |
| |
Enumeration Constants | |
| |
| |
| |
C File Processing | |
| |
| |
| |
Introduction | |
| |
| |
| |
The Data Hierarchy | |
| |
| |
| |
Files and Streams | |
| |
| |
| |
Creating a Sequential-Access File | |
| |
| |
| |
Reading Data from a Sequential-Access File | |
| |
| |
| |
Random-Access Files | |
| |
| |
| |
Creating a Randomly Accessed File | |
| |
| |
| |
Writing Data Randomly to a Randomly Accessed File | |
| |
| |
| |
Reading Data Randomly from a Randomly Accessed File | |
| |
| |
| |
Case Study: A Transaction-Processing Program | |
| |
| |
| |
C Data Structures | |
| |
| |
| |
Introduction | |
| |
| |
| |
Self-Referential Structures | |
| |
| |
| |
Dynamic Memory Allocation | |
| |
| |
| |
Linked Lists | |
| |
| |
| |
Stacks | |
| |
| |
| |
Queues | |
| |
| |
| |
Trees | |
| |
| |
| |
C Preprocessor | |
| |
| |
| |
Introduction | |
| |
| |
| |
The #include Preprocessor Directive | |
| |
| |
| |
The #define Preprocessor Directive: Symbolic Constants | |
| |
| |
| |
The #define Preprocessor Directive: Macros | |
| |
| |
| |
Conditional Compilation | |
| |
| |
| |
The #error and #pragma Preprocessor Directives | |
| |
| |
| |
The # and ## Operators | |
| |
| |
| |
Line Numbers | |
| |
| |
| |
Predefined Symbolic Constants | |
| |
| |
| |
Assertions | |
| |
| |
| |
Advanced C Topics | |
| |
| |
| |
Introduction | |
| |
| |
| |
Redirecting Input/Output on UNIX and DOS Systems | |
| |
| |
| |
Variable-Length Argument Lists | |
| |
| |
| |
Using Command-Line Arguments | |
| |
| |
| |
Notes on Compiling Multiple-Source-File Programs | |
| |
| |
| |
Program Termination with exit and atexit | |
| |
| |
| |
The volatile Type Qualifier | |
| |
| |
| |
Suffixes for Integer and Floating-Point Constants | |
| |
| |
| |
More on Files | |
| |
| |
| |
Signal Handling | |
| |
| |
| |
Dynamic Memory Allocation: Functions calloc and realloc | |
| |
| |
| |
The Unconditional Branch: goto | |
| |
| |
| |
C++ as a "Better C" | |
| |
| |
| |
Introduction | |
| |
| |
| |
C++ | |
| |
| |
| |
A Simple Program: Adding Two Integers | |
| |
| |
| |
C++ Standard Library | |
| |
| |
| |
Header Files | |
| |
| |
| |
Inline Functions | |
| |
| |
| |
References and Reference Parameters | |
| |
| |
| |
Default Arguments and Empty Parameter Lists | |
| |
| |
| |
Unary Scope Resolution Operator | |
| |
| |
| |
Function Overloading | |
| |
| |
| |
Function Templates | |
| |
| |
| |
C++ Classes and Data Abstraction | |
| |
| |
| |
Introduction | |
| |
| |
| |
Implementing a Time Abstract Data Type with a Class | |
| |
| |
| |
Class Scope and Accessing Class Members | |
| |
| |
| |
Separating Interface from Implementation | |
| |
| |
| |
Controlling Access to Members | |
| |
| |
| |
Access Functions and Utility Functions | |
| |
| |
| |
Initializing Class Objects: Constructors | |
| |
| |
| |
Using Default Arguments with Constructors | |
| |
| |
| |
Using Destructors | |
| |
| |
| |
When Constructors and Destructors Are Called | |
| |
| |
| |
Using Data Members and Member Functions | |
| |
| |
| |
A Subtle Trap: Returning a Reference to a private Data Member | |
| |
| |
| |
Assignment by Default Memberwise Copy | |
| |
| |
| |
Software Reusability | |
| |
| |
| |
C++ Classes: Part II | |
| |
| |
| |
Introduction | |
| |
| |
| |
const (Constant) Objects and const Member Functions | |
| |
| |
| |
Composition: Objects as Members of Classes | |
| |
| |
| |
friend Functions and friend Classes | |
| |
| |
| |
Using the this Pointer | |
| |
| |
| |
Dynamic Memory Allocation with Operators new and delete | |
| |
| |
| |
static Class Members | |
| |
| |
| |
Data Abstraction and Information Hiding | |
| |
| |
| |
Example: Array Abstract Data Type | |
| |
| |
| |
Example: String Abstract Data Type | |
| |
| |
| |
Example: Queue Abstract Data Type | |
| |
| |
| |
Container Classes and Iterators | |
| |
| |
| |
C++ Operator Overloading | |
| |
| |
| |
Introduction | |
| |
| |
| |
Fundamentals of Operator Overloading | |
| |
| |
| |
Restrictions on Operator Overloading | |
| |
| |
| |
Operator Functions as Class Members vs. as friend Functions | |
| |
| |
| |
Overloading Stream-Insertion and Stream-Extraction Operators | |
| |
| |
| |
Overloading Unary Operators | |
| |
| |
| |
Overloading Binary Operators | |
| |
| |
| |
Case Study: An Array Class | |
| |
| |
| |
Converting between Types | |
| |
| |
| |
Overloading ++ and -- | |
| |
| |
| |
C++ Inheritance | |
| |
| |
| |
Introduction | |
| |
| |
| |
Inheritance: Base Classes and Derived Classes | |
| |
| |
| |
Protected Members | |
| |
| |
| |
Casting Base-Class Pointers to Derived-Class Pointers | |
| |
| |
| |
Using Member Functions | |
| |
| |
| |
Overriding Base-Class Members in a Derived Class | |
| |
| |
| |
Public, Protected and Private Inheritance | |
| |
| |
| |
Direct Base Classes and Indirect Base Classes | |
| |
| |
| |
Using Constructors and Destructors in Derived Classes | |
| |
| |
| |
Implicit Derived-Class Object to Base-Class Object Conversion | |
| |
| |
| |
Software Engineering with Inheritance | |
| |
| |
| |
Composition vs. Inheritance | |
| |
| |
| |
"Uses A" and "Knows A" Relationships | |
| |
| |
| |
Case Study: Point, Circle, Cylinder | |
| |
| |
| |
C++ Virtual Functions and Polymorphism | |
| |
| |
| |
Introduction | |
| |
| |
| |
Type Fields and switch Statements | |
| |
| |
| |
Virtual Functions | |
| |
| |
| |
Abstract Base Classes and Concrete Classes | |
| |
| |
| |
Polymorphism | |
| |
| |
| |
New Classes and Dynamic Binding | |
| |
| |
| |
Virtual Destructors | |
| |
| |
| |
Case Study: Inheriting Interface and Implementation | |
| |
| |
| |
Polymorphism, virtual Functions and Dynamic Binding "Under the Hood" | |
| |
| |
| |
C++ Stream Input/Output | |
| |
| |
| |
Introduction | |
| |
| |
| |
Streams | |
| |
| |
| |
Iostream Library Header Files | |
| |
| |
| |
Stream Input/Output Classes and Objects | |
| |
| |
| |
Stream Output | |
| |
| |
| |
Stream-Insertion Operator | |
| |
| |
| |
Cascading Stream-Insertion/Extraction Operators | |
| |
| |
| |
Output of char * Variables | |
| |
| |
| |
Character Output with Member Function put; Cascading puts | |
| |
| |
| |
Stream Input | |
| |
| |
| |
Stream-Extraction Operator | |
| |
| |
| |
get and getline Member Functions | |
| |
| |
| |
istream Member Functions peek, putback and ignore | |
| |
| |
| |
Type-Safe I/O | |
| |
| |
| |
Unformatted I/O with read, gcount and write | |
| |
| |
| |
Stream Manipulators | |
| |
| |
| |
Integral Stream Base: dec, oct, hex and setbase | |
| |
| |
| |
Floating-Point Precision (precision, setprecision) | |
| |
| |
| |
Field Width (setw, width) | |
| |
| |
| |
User-Defined Manipulators | |
| |
| |
| |
Stream Format States | |
| |
| |
| |
Format State Flags | |
| |
| |
| |
Trailing Zeros and Decimal Points (ios::showpoint) | |
| |
| |
| |
Justification (ios::left, ios::right, ios::internal) | |
| |
| |
| |
Padding (fill, setfill) | |
| |
| |
| |
Integral Stream Base (ios::dec, ios::oct, ios::hex, ios::showbase) | |
| |
| |
| |
Floating-Point Numbers; Scientific Notation (ios::scientific, ios::fixed) | |
| |
| |
| |
Uppercase/Lowercase Control (ios::uppercase) | |
| |
| |
| |
Setting and Resetting the Format Flags (flags, setiosflags, resetiosflags) | |
| |
| |
| |
Stream Error States | |
| |
| |
| |
Tying an Output Stream to an Input Stream | |
| |
| |
| |
C++ Templates | |
| |
| |
| |
Introduction | |
| |
| |
| |
Class Templates | |
| |
| |
| |
Class Templates and Nontype Parameters | |
| |
| |
| |
Templates and Inheritance | |
| |
| |
| |
Templates and friends | |
| |
| |
| |
Templates and static Members | |
| |
| |
| |
C++ Exception Handling | |
| |
| |
| |
Introduction | |
| |
| |
| |
When Exception Handling Should Be Used | |
| |
| |
| |
Other Error-Handling Techniques | |
| |
| |
| |
Basics of C++ Exception Handling: try, throw, catch | |
| |
| |
| |
A Simple Exception-Handling Example: Divide by Zero | |
| |
| |
| |
Throwing an Exception | |
| |
| |
| |
Catching an Exception | |
| |
| |
| |
Rethrowing an Exception | |
| |
| |
| |
Exception Specifications | |
| |
| |
| |
Processing Unexpected Exceptions | |
| |
| |
| |
Stack Unwinding | |
| |
| |
| |
Constructors, Destructors and Exception Handling | |
| |
| |
| |
Exceptions and Inheritance | |
| |
| |
| |
Processing new Failures | |
| |
| |
| |
Class auto_ptr and Dynamic Memory Allocation | |
| |
| |
| |
Standard Library Exception Hierarchy | |
| |
| |
| |
Introduction to Java Applications and Applets | |
| |
| |
| |
Introduction | |
| |
| |
| |
Basics of a Typical Java Environment | |
| |
| |
| |
General Notes about Java and This Book | |
| |
| |
| |
A Simple Program: Printing a Line of Text | |
| |
| |
| |
Another Java Application: Adding Integers | |
| |
| |
| |
Sample Applets from the Java 2 Software Development Kit | |
| |
| |
| |
The TicTacToe Applet | |
| |
| |
| |
The DrawTest Applet | |
| |
| |
| |
The Java2D Applet | |
| |
| |
| |
A Simple Java Applet: Drawing a String | |
| |
| |
| |
Two More Simple Applets: Drawing Strings and Lines | |
| |
| |
| |
Another Java Applet: Adding Integers | |
| |
| |
| |
Beyond C and C++: Operators, Methods and Arrays in Java | |
| |
| |
| |
Introduction | |
| |
| |
| |
Primitive Data Types and Keywords | |
| |
| |
| |
Logical Operators | |
| |
| |
| |
Method Definitions | |
| |
| |
| |
Java API Packages | |
| |
| |
| |
Random Number Generation | |
| |
| |
| |
Example: A Game of Chance | |
| |
| |
| |
Methods of Class JApplet | |
| |
| |
| |
Declaring and Allocating Arrays | |
| |
| |
| |
Examples Using Arrays | |
| |
| |
| |
References and Reference Parameters | |
| |
| |
| |
Multiple-Subscripted Arrays | |
| |
| |
| |
Java Object-Based Programming | |
| |
| |
| |
Introduction | |
| |
| |
| |
Implementing a Time Abstract Data Type with a Class | |
| |
| |
| |
Class Scope | |
| |
| |
| |
Creating Packages | |
| |
| |
| |
Initializing Class Objects: Constructors | |
| |
| |
| |
Using Set and Get Methods | |
| |
| |
| |
Using the this Reference | |
| |
| |
| |
Finalizers | |
| |
| |
| |
Static Class Members | |
| |
| |
| |
Java Object-Oriented Programming | |
| |
| |
| |
Introduction | |
| |
| |
| |
Superclasses and Subclasses | |
| |
| |
| |
protected Members | |
| |
| |
| |
Relationship between Superclass Objects and Subclass Objects | |
| |
| |
| |
Implicit Subclass-Object-to-Superclass-Object Conversion | |
| |
| |
| |
Software Engineering with Inheritance | |
| |
| |
| |
Composition vs. Inheritance | |
| |
| |
| |
Introduction to Polymorphism | |
| |
| |
| |
Type Fields and switch Statements | |
| |
| |
| |
Dynamic Method Binding | |
| |
| |
| |
final Methods and Classes | |
| |
| |
| |
Abstract Superclasses and Concrete Classes | |
| |
| |
| |
Polymorphism Example | |
| |
| |
| |
New Classes and Dynamic Binding | |
| |
| |
| |
Case Study: Inheriting Interface and Implementation | |
| |
| |
| |
Case Study: Creating and Using Interfaces | |
| |
| |
| |
Inner Class Definitions | |
| |
| |
| |
Notes on Inner Class Definitions | |
| |
| |
| |
Type-Wrapper Classes for Primitive Types | |
| |
| |
| |
Java Graphics and Java2D | |
| |
| |
| |
Introduction | |
| |
| |
| |
Graphics Contexts and Graphics Objects | |
| |
| |
| |
Color Control | |
| |
| |
| |
Font Control | |
| |
| |
| |
Drawing Lines, Rectangles and Ovals | |
| |
| |
| |
Drawing Arcs | |
| |
| |
| |
Drawing Polygons and Polylines | |
| |
| |
| |
The Java2D API | |
| |
| |
| |
Java2D Shapes | |
| |
| |
| |
Java Graphical User Interface Components | |
| |
| |
| |
Introduction | |
| |
| |
| |
Swing Overview | |
| |
| |
| |
JLabel | |
| |
| |
| |
Event Handling Model | |
| |
| |
| |
JTextField and JPasswordField | |
| |
| |
| |
How Event Handling Works | |
| |
| |
| |
JTextArea | |
| |
| |
| |
JButton | |
| |
| |
| |
JCheckBox | |
| |
| |
| |
JComboBox | |
| |
| |
| |
Mouse Event Handling | |
| |
| |
| |
Layout Managers | |
| |
| |
| |
FlowLayout | |
| |
| |
| |
BorderLayout | |
| |
| |
| |
GridLayout | |
| |
| |
| |
Panels | |
| |
| |
| |
Creating a Self-Contained Subclass of JPanel | |
| |
| |
| |
Windows | |
| |
| |
| |
Using Menus with Frames | |
| |
| |
| |
Java Multimedia: Images, Animation and Audio | |
| |
| |
| |
Introduction | |
| |
| |
| |
Loading, Displaying and Scaling Images | |
| |
| |
| |
Loading and Playing Audio Clips | |
| |
| |
| |
Animating a Series of Images | |
| |
| |
| |
Animation Issues | |
| |
| |
| |
Customizing Applets via the HTML param Tag | |
| |
| |
| |
Image Maps | |
| |
| |
| |
Java Plug-In | |
| |
| |
| |
Internet and World Wide Web Resources | |
| |
| |
| |
Internet and Web Resources | |
| |
| |
| |
C/C++ Resources | |
| |
| |
| |
C++ Tutorials | |
| |
| |
| |
C/C++ FAQs | |
| |
| |
| |
Visual C++ | |
| |
| |
| |
comp.lang.c++ | |
| |
| |
| |
C/C++ Compilers | |
| |
| |
| |
C++ Development Tools | |
| |
| |
| |
Java Resources | |
| |
| |
| |
Java Products | |
| |
| |
| |
Java FAQs | |
| |
| |
| |
Java Tutorials | |
| |
| |
| |
Java Magazines | |
| |
| |
| |
Java Applets | |
| |
| |
| |
Multimedia | |
| |
| |
| |
Java Newsgroups | |
| |
| |
| |
C99 Internet and Web Resources | |
| |
| |
| |
C99 Resources | |
| |
| |
| |
Operator Precedence Charts | |
| |
| |
| |
ASCII Character Set | |
| |
| |
| |
Number Systems | |
| |
| |
| |
Introduction | |
| |
| |
| |
Abbreviating Binary Numbers as Octal Numbers and Hexadecimal Numbers | |
| |
| |
| |
Converting Octal Numbers and Hexadecimal Numbers to Binary Numbers | |
| |
| |
| |
Converting from Binary, Octal, or Hexadecimal to Decimal | |
| |
| |
| |
Converting from Decimal to Binary, Octal, or Hexadecimal | |
| |
| |
| |
Negative Binary Numbers: Two's Complement Notation | |
| |
| |
Index | |