| |
| |
Preface | |
| |
| |
| |
Introduction to Computers, the Internet and the Web | |
| |
| |
| |
Introduction | |
| |
| |
| |
Computers: Hardware and Software | |
| |
| |
| |
Computer Organization | |
| |
| |
| |
Personal, Distributed and Client/Server Computing | |
| |
| |
| |
The Internet and the World Wide Web | |
| |
| |
| |
Machine Languages, Assembly Languages and High-Level Languages | |
| |
| |
| |
History of C | |
| |
| |
| |
C Standard Library | |
| |
| |
| |
C++ | |
| |
| |
| |
Java | |
| |
| |
| |
Fortran, COBOL, Pascal and Ada | |
| |
| |
| |
BASIC, Visual Basic, Visual C++, C# and .NET | |
| |
| |
| |
Key Software Trend: Object Technology | |
| |
| |
| |
Typical C Program Development Environment | |
| |
| |
| |
Hardware Trends | |
| |
| |
| |
Notes About C and This Book | |
| |
| |
| |
Web Resources | |
| |
| |
| |
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 Statement | |
| |
| |
| |
The if…else Selection Statement | |
| |
| |
| |
The while Repetition Statement | |
| |
| |
| |
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 | |
| |
| |
| |
Repetition Essentials | |
| |
| |
| |
Counter-Controlled Repetition | |
| |
| |
| |
for Repetition Statement | |
| |
| |
| |
for Statement: Notes and Observations | |
| |
| |
| |
Examples Using the for Statement | |
| |
| |
| |
switch Multiple-Selection Statement | |
| |
| |
| |
do…while Repetition Statement | |
| |
| |
| |
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 | |
| |
| |
| |
Function Call Stack and Activation Records | |
| |
| |
| |
Headers | |
| |
| |
| |
Calling Functions By Value and By Reference | |
| |
| |
| |
Random Number Generation | |
| |
| |
| |
Example: A Game of Chance | |
| |
| |
| |
Storage Classes | |
| |
| |
| |
Scope Rules | |
| |
| |
| |
Recursion | |
| |
| |
| |
Example Using Recursion: Fibonacci Series | |
| |
| |
| |
Recursion vs. Iteration | |
| |
| |
| |
C Arrays | |
| |
| |
| |
Introduction | |
| |
| |
| |
Arrays | |
| |
| |
| |
Defining Arrays | |
| |
| |
| |
Array Examples | |
| |
| |
| |
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 Definitions and Initialization | |
| |
| |
| |
Pointer Operators | |
| |
| |
| |
Passing Arguments to Functions by Reference | |
| |
| |
| |
Using the const Qualifier with Pointers | |
| |
| |
| |
Bubble Sort Using Call-by-Reference | |
| |
| |
| |
sizeof Operator | |
| |
| |
| |
Pointer Expressions and Pointer Arithmetic | |
| |
| |
| |
Relationship between Pointers and Arrays | |
| |
| |
| |
Arrays of Pointers | |
| |
| |
| |
Case Study: 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 Precision | |
| |
| |
| |
Using Flags in the printf Format Control String | |
| |
| |
| |
Printing Literals and Escape Sequences | |
| |
| |
| |
Reading Formatted Input with scanf | |
| |
| |
| |
C Structures, Unions, Bit Manipulations and Enumerations | |
| |
| |
| |
Introduction | |
| |
| |
| |
Structure Definitions | |
| |
| |
| |
Initializing Structures | |
| |
| |
| |
Accessing Structure Members | |
| |
| |
| |
Using Structures with Functions | |
| |
| |
| |
typedef | |
| |
| |
| |
Example: High-Performance Card Shuffling and Dealing Simulation | |
| |
| |
| |
Unions | |
| |
| |
| |
Bitwise Operators | |
| |
| |
| |
Bit Fields | |
| |
| |
| |
Enumeration Constants | |
| |
| |
| |
C File Processing | |
| |
| |
| |
Introduction | |
| |
| |
| |
Data Hierarchy | |
| |
| |
| |
Files and Streams | |
| |
| |
| |
Creating a Sequential-Access File | |
| |
| |
| |
Reading Data from a Sequential-Access File | |
| |
| |
| |
Random-Access Files | |
| |
| |
| |
Creating a Random-Access File | |
| |
| |
| |
Writing Data Randomly to a Random-Access File | |
| |
| |
| |
Reading Data from a Random-Access File | |
| |
| |
| |
Case Study: Transaction-Processing Program | |
| |
| |
| |
C Data Structures | |
| |
| |
| |
Introduction | |
| |
| |
| |
Self-Referential Structures | |
| |
| |
| |
Dynamic Memory Allocation | |
| |
| |
| |
Linked Lists | |
| |
| |
| |
Stacks | |
| |
| |
| |
Queues | |
| |
| |
| |
Trees | |
| |
| |
| |
C Preprocessor | |
| |
| |
| |
Introduction | |
| |
| |
| |
#include Preprocessor Directive | |
| |
| |
| |
#define Preprocessor Directive: Symbolic Constants | |
| |
| |
| |
#define Preprocessor Directive: Macros | |
| |
| |
| |
Conditional Compilation | |
| |
| |
| |
#error and #pragma Preprocessor Directives | |
| |
| |
| |
# and ## Operators | |
| |
| |
| |
Line Numbers | |
| |
| |
| |
Predefined Symbolic Constants | |
| |
| |
| |
Assertions | |
| |
| |
| |
Other C Topics | |
| |
| |
| |
Introduction | |
| |
| |
| |
Redirecting I/O | |
| |
| |
| |
Variable-Length Argument Lists | |
| |
| |
| |
Using Command-Line Arguments | |
| |
| |
| |
Notes on Compiling Multiple-Source-File Programs | |
| |
| |
| |
Program Termination with exit and atexit | |
| |
| |
| |
volatile Type Qualifier | |
| |
| |
| |
Suffixes for Integer and Floating-Point Constants | |
| |
| |
| |
More on Files | |
| |
| |
| |
Signal Handling | |
| |
| |
| |
Dynamic Memory Allocation: Functions calloc and realloc | |
| |
| |
| |
Unconditional Branching with goto | |
| |
| |
| |
C++ as a Better C; Introducing Object Technology | |
| |
| |
| |
Introduction | |
| |
| |
| |
C++ | |
| |
| |
| |
A Simple Program: Adding Two Integers | |
| |
| |
| |
C++ Standard Library | |
| |
| |
| |
Header Files | |
| |
| |
| |
Inline Functions | |
| |
| |
| |
References and Reference Parameters | |
| |
| |
| |
Empty Parameter Lists | |
| |
| |
| |
Default Arguments | |
| |
| |
| |
Unary Scope Resolution Operator | |
| |
| |
| |
Function Overloading | |
| |
| |
| |
Function Templates | |
| |
| |
| |
Introduction to Object Technology and the UML | |
| |
| |
| |
Wrap-Up | |
| |
| |
| |
Introduction to Classes and Objects | |
| |
| |
| |
Introduction | |
| |
| |
| |
Classes, Objects, Member Functions and Data Members | |
| |
| |
| |
Defining a Class with a Member Function | |
| |
| |
| |
Defining a Member Function with a Parameter | |
| |
| |
| |
Data Members, set Functions and get Functions | |
| |
| |
| |
Initializing Objects with Constructors | |
| |
| |
| |
Placing a Class in a Separate File for Reusability | |
| |
| |
| |
Separating Interface from Implementation | |
| |
| |
| |
Validating Data with set Functions | |
| |
| |
| |
Wrap-Up | |
| |
| |
| |
Classes: A Deeper Look, Part 1 | |
| |
| |
| |
Introduction | |
| |
| |
| |
Time Class Case Study | |
| |
| |
| |
Class Scope and Accessing Class Members | |
| |
| |
| |
Separating Interface from Implementation | |
| |
| |
| |
Access Functions and Utility Functions | |
| |
| |
| |
Time Class Case Study: Constructors with Default Arguments | |
| |
| |
| |
Destructors | |
| |
| |
| |
When Constructors and Destructors are Called | |
| |
| |
| |
Time Class Case Study: A Subtle Trap-Returning a Reference to a private Data Member | |
| |
| |
| |
Default Memberwise Assignment | |
| |
| |
| |
Wrap-Up | |
| |
| |
| |
Classes: A Deeper Look, Part 2 | |
| |
| |
| |
Introduction | |
| |
| |
| |
const (Constant) Objects and const Member Functions | |
| |
| |
| |
Composition: Objects as Members of Classes | |
| |
| |
| |
friend Functions and friend Classes | |
| |
| |
| |
Using the this Pointer | |
| |
| |
| |
static Class Members | |
| |
| |
| |
Data Abstraction and Information Hiding | |
| |
| |
| |
Wrap-Up | |
| |
| |
| |
Operator Overloading | |
| |
| |
| |
Introduction | |
| |
| |
| |
Fundamentals of Operator Overloading | |
| |
| |
| |
Restrictions on Operator Overloading | |
| |
| |
| |
Operator Functions as Class Members vs. Global Function | |
| |
| |
| |
Overloading Stream Insertion and Stream Extraction Operators | |
| |
| |
| |
Overloading Unary Operators | |
| |
| |
| |
Overloading Binary Operators | |
| |
| |
| |
Dynamic Memory Management | |
| |
| |
| |
Case Study: Array Class | |
| |
| |
| |
Converting between Types | |
| |
| |
| |
Building a String Class | |
| |
| |
| |
Overloading ++ and -- | |
| |
| |
| |
Case Study: A Date Class | |
| |
| |
| |
Standard Library Class string | |
| |
| |
| |
explicit Constructors | |
| |
| |
| |
Proxy Classes | |
| |
| |
| |
Wrap-Up | |
| |
| |
| |
Object-Oriented Programming: Inheritance | |
| |
| |
| |
Introduction | |
| |
| |
| |
Base Classes and Derived Classes | |
| |
| |
| |
protected Members | |
| |
| |
| |
Relationship between Base Classes and Derived Classes | |
| |
| |
| |
Creating and Using a CommissionEmployee Class | |
| |
| |
| |
Creating a BasePlusCommissionEmployee Class Without Using Inheritance | |
| |
| |
| |
Creating a CommissionEmployee-BasePlusCommissionEmployee Inheritance Hierarchy | |
| |
| |
| |
CommissionEmployee-BasePlusCommissionEmployee Inheritance Hierarchy Using protected Data | |
| |
| |
| |
CommissionEmployee-BasePlusCommissionEmployee Inheritance Hierarchy Using private Data | |
| |
| |
| |
Constructors and Destructors in Derived Classes | |
| |
| |
| |
public, protected and private Inheritance | |
| |
| |
| |
Software Engineering with Inheritance | |
| |
| |
| |
Wrap-Up | |
| |
| |
| |
Object-Oriented Programming: Polymorphism | |
| |
| |
| |
Introduction | |
| |
| |
| |
Polymorphism Examples | |