| Preface |
|
xiii | |
|
Introduction to Computers and Programming |
|
|
1 | (28) |
|
|
|
1 | (1) |
|
Computer Systems: Hardware and Software |
|
|
2 | (4) |
|
Programs and Programming Languages |
|
|
6 | (6) |
|
What Is a Program Made of? |
|
|
12 | (4) |
|
Input, Processing, and Output |
|
|
16 | (1) |
|
|
|
17 | (4) |
|
Procedural and Object-Oriented Programming |
|
|
21 | (8) |
|
|
|
29 | (52) |
|
The Parts of a C++ Program |
|
|
29 | (4) |
|
|
|
33 | (4) |
|
|
|
37 | (2) |
|
|
|
39 | (3) |
|
|
|
42 | (2) |
|
|
|
44 | (4) |
|
|
|
48 | (5) |
|
Floating-Point Data Types |
|
|
53 | (4) |
|
|
|
57 | (1) |
|
Determining the Size of a Data Type |
|
|
58 | (1) |
|
Variable Assignments and Initialization |
|
|
59 | (1) |
|
|
|
60 | (1) |
|
|
|
61 | (4) |
|
|
|
65 | (2) |
|
Focus on Software Engineering: Programming Style |
|
|
67 | (2) |
|
If You Plan to Continue in Computer Science: Standard and Prestandard C++ |
|
|
69 | (12) |
|
Expressions and Interactivity |
|
|
81 | (82) |
|
|
|
81 | (8) |
|
|
|
89 | (8) |
|
When You Mix Apples and Oranges: Type Conversion |
|
|
97 | (2) |
|
|
|
99 | (1) |
|
|
|
100 | (4) |
|
|
|
104 | (5) |
|
Multiple Assignment and Combined Assignment |
|
|
109 | (4) |
|
|
|
113 | (10) |
|
|
|
123 | (5) |
|
Focus on Object-Oriented Programming: More About Member Functions |
|
|
128 | (1) |
|
More Mathematical Library Functions |
|
|
128 | (4) |
|
Focus on Debugging: Hand Tracing a Program |
|
|
132 | (2) |
|
Focus on Problem Solving: A Case Study |
|
|
134 | (4) |
|
Introduction to File Input and Output |
|
|
138 | (25) |
|
|
|
163 | (84) |
|
|
|
163 | (5) |
|
|
|
168 | (8) |
|
|
|
176 | (1) |
|
Expanding the if Statement |
|
|
177 | (4) |
|
|
|
181 | (3) |
|
|
|
184 | (5) |
|
|
|
189 | (1) |
|
|
|
190 | (2) |
|
Focus on Software Engineering: Nested if Statements |
|
|
192 | (6) |
|
|
|
198 | (6) |
|
Checking Numeric Ranges with Logical Operators |
|
|
204 | (2) |
|
Focus on Software Engineering: Validating User Input |
|
|
206 | (2) |
|
More About Variable Definitions and Scope |
|
|
208 | (4) |
|
|
|
212 | (5) |
|
|
|
217 | (4) |
|
|
|
221 | (9) |
|
Testing for File Open Errors |
|
|
230 | (17) |
|
|
|
247 | (52) |
|
The Increment and Decrement Operators |
|
|
247 | (5) |
|
Introduction to Loops: The while Loop |
|
|
252 | (5) |
|
Using the while Loop for Input Validation |
|
|
257 | (3) |
|
|
|
260 | (1) |
|
|
|
261 | (5) |
|
|
|
266 | (9) |
|
|
|
275 | (1) |
|
|
|
276 | (2) |
|
Using a Loop to Read Data from a File |
|
|
278 | (3) |
|
Focus on Software Engineering: Deciding Which Loop to Use |
|
|
281 | (1) |
|
|
|
281 | (3) |
|
|
|
284 | (2) |
|
|
|
286 | (13) |
|
|
|
299 | (78) |
|
Focus on Software Engineering: Modular Programming |
|
|
299 | (2) |
|
Defining and Calling Functions |
|
|
301 | (8) |
|
|
|
309 | (2) |
|
Sending Data into a Function |
|
|
311 | (5) |
|
|
|
316 | (2) |
|
Focus on Software Engineering: Using Functions in a Menu-Driven Program |
|
|
318 | (4) |
|
|
|
322 | (2) |
|
Returning a Value from a Function |
|
|
324 | (6) |
|
Returning a Boolean Value |
|
|
330 | (2) |
|
Local and Global Variables |
|
|
332 | (7) |
|
|
|
339 | (4) |
|
|
|
343 | (4) |
|
Using Reference Variables as Parameters |
|
|
347 | (5) |
|
|
|
352 | (5) |
|
|
|
357 | (2) |
|
|
|
359 | (18) |
|
|
|
377 | (78) |
|
Arrays Hold Multiple Values |
|
|
377 | (2) |
|
|
|
379 | (7) |
|
No Bounds Checking in C++ |
|
|
386 | (3) |
|
|
|
389 | (5) |
|
Processing Array Contents |
|
|
394 | (8) |
|
Focus on Software Engineering: Using Parallel Arrays |
|
|
402 | (3) |
|
Arrays as Function Arguments |
|
|
405 | (10) |
|
|
|
415 | (7) |
|
|
|
422 | (2) |
|
Arrays with Three or More Dimensions |
|
|
424 | (2) |
|
Focus on Problem Solving and Program Design: A Case Study |
|
|
426 | (2) |
|
If You Plan to Continue in Computer Science: Introduction to the STL vector |
|
|
428 | (27) |
|
Searching and Sorting Arrays |
|
|
455 | (40) |
|
Focus on Software Engineering: Introduction to Search Algorithms |
|
|
455 | (7) |
|
Focus on Problem Solving and Program Design: A Case Study |
|
|
462 | (6) |
|
Focus on Software Engineering: Introduction to Sorting Algorithms |
|
|
468 | (8) |
|
Focus on Problem Solving and Program Design: A Case Study |
|
|
476 | (8) |
|
If You Plan to Continue in Computer Science: Sorting and Searching vectors |
|
|
484 | (11) |
|
|
|
495 | (48) |
|
Getting the Address of a Variable |
|
|
495 | (2) |
|
|
|
497 | (7) |
|
The Relationship Between Arrays and Pointers |
|
|
504 | (4) |
|
|
|
508 | (2) |
|
|
|
510 | (1) |
|
|
|
511 | (2) |
|
Pointers as Function Parameters |
|
|
513 | (9) |
|
Focus on Software Engineering: Dynamic Memory Allocation |
|
|
522 | (4) |
|
Focus on Software Engineering: Returning Pointers from Functions |
|
|
526 | (4) |
|
Focus on Problems Solving and Program Design: A Case Study |
|
|
530 | (13) |
|
Characters, Strings, and the string Class |
|
|
543 | (48) |
|
|
|
543 | (4) |
|
Character Case Conversion |
|
|
547 | (3) |
|
Review of the Internal Storage of C-Strings |
|
|
550 | (3) |
|
Library Functions for Working with C-Strings |
|
|
553 | (8) |
|
String/Numeric Conversion Functions |
|
|
561 | (5) |
|
Focus on Software Engineering: Writing Your Own C-String-Handling Functions |
|
|
566 | (6) |
|
|
|
572 | (10) |
|
Focus on Problem Solving and Program Design: A Case Study |
|
|
582 | (9) |
|
|
|
591 | (64) |
|
|
|
591 | (2) |
|
Focus on Software Engineering: Combining Data into Structures |
|
|
593 | (3) |
|
Accessing Structure Members |
|
|
596 | (5) |
|
|
|
601 | (4) |
|
|
|
605 | (3) |
|
Focus on Software Engineering: Nested Structures |
|
|
608 | (4) |
|
Structures as Function Arguments |
|
|
612 | (3) |
|
Returning a Structure from a Function |
|
|
615 | (3) |
|
|
|
618 | (3) |
|
Focus on Software Engineering: When to Use . , When to Use ->, and When to Use * |
|
|
621 | (2) |
|
|
|
623 | (4) |
|
|
|
627 | (28) |
|
|
|
655 | (56) |
|
|
|
655 | (7) |
|
|
|
662 | (3) |
|
Passing File Stream Objects to Functions |
|
|
665 | (2) |
|
More Detailed Error Testing |
|
|
667 | (3) |
|
Member Functions for Reading and Writing Files |
|
|
670 | (7) |
|
Focus on Software Engineering: Working with Multiple Files |
|
|
677 | (1) |
|
|
|
678 | (6) |
|
Creating Records with Structures |
|
|
684 | (4) |
|
|
|
688 | (8) |
|
Opening a File for Both Input and Output |
|
|
696 | (15) |
|
|
|
711 | (96) |
|
Procedural and Object-Oriented Programming |
|
|
711 | (7) |
|
|
|
718 | (5) |
|
Defining an Instance of a Class |
|
|
723 | (11) |
|
Why Have Private Members? |
|
|
734 | (1) |
|
Focus on Software Engineering: Separating Class Specification from Implementation |
|
|
735 | (6) |
|
|
|
741 | (3) |
|
|
|
744 | (4) |
|
Passing Arguments to Constructors |
|
|
748 | (8) |
|
|
|
756 | (4) |
|
|
|
760 | (4) |
|
|
|
764 | (2) |
|
|
|
766 | (4) |
|
Focus on Problem Solving and Program Design: An OOP Case Study |
|
|
770 | (7) |
|
Focus on Object-Oriented Programming: Creating an Abstract Array Data Type |
|
|
777 | (4) |
|
Focus on Object-Oriented Design: The Unified Modeling Language (UML) |
|
|
781 | (3) |
|
Focus on Object-Oriented Design: Finding the Classes and Their Responsibilities |
|
|
784 | (23) |
|
|
|
807 | (70) |
|
Instance and Static Members |
|
|
807 | (8) |
|
|
|
815 | (5) |
|
|
|
820 | (1) |
|
|
|
821 | (4) |
|
|
|
825 | (27) |
|
|
|
852 | (2) |
|
|
|
854 | (6) |
|
Focus on Object-Oriented Design: Class Collaborations |
|
|
860 | (17) |
|
Inheritance, Polymorphism, and Virtual Functions |
|
|
877 | (74) |
|
|
|
877 | (9) |
|
Protected Members and Class Access |
|
|
886 | (6) |
|
Constructors and Destructors in Base and Derived Classes |
|
|
892 | (7) |
|
Redefining Base Class Functions |
|
|
899 | (4) |
|
|
|
903 | (6) |
|
Polymorphism and Virtual Member Functions |
|
|
909 | (15) |
|
Abstract Base Classes and Pure Virtual Functions |
|
|
924 | (7) |
|
|
|
931 | (20) |
|
Exceptions, Templates, and the Standard Template Library (STL) |
|
|
951 | (56) |
|
|
|
951 | (19) |
|
|
|
970 | (6) |
|
Focus on Software Engineering: Where to Start When Defining Templates |
|
|
976 | (1) |
|
|
|
977 | (10) |
|
Introduction to the Standard Template Library (STL) |
|
|
987 | (20) |
|
|
|
1007 | (40) |
|
Introduction to the Linked List ADT |
|
|
1007 | (2) |
|
|
|
1009 | (17) |
|
|
|
1026 | (12) |
|
Variations of the Linked List |
|
|
1038 | (1) |
|
|
|
1039 | (8) |
|
|
|
1047 | (40) |
|
Introduction to the Stack ADT |
|
|
1047 | (11) |
|
|
|
1058 | (5) |
|
|
|
1063 | (2) |
|
Introduction to the Queue ADT |
|
|
1065 | (8) |
|
|
|
1073 | (4) |
|
The STL deque and queue Containers |
|
|
1077 | (10) |
|
|
|
1087 | (38) |
|
Introduction to Recursion |
|
|
1087 | (5) |
|
Solving Problems with Recursion |
|
|
1092 | (7) |
|
Focus on Problem Solving and Program Design: The Recursive gcd Function |
|
|
1099 | (1) |
|
Focus on Problem Solving and Program Design: Solving Recursively Defined Problems |
|
|
1100 | (2) |
|
Focus on Problem Solving and Program Design: Recursive Linked List Operations |
|
|
1102 | (3) |
|
Focus on Problem Solving and Program Design: A Recursive Binary Search Function |
|
|
1105 | (3) |
|
|
|
1108 | (3) |
|
Focus on Problem Solving and Program Design: The QuickSort Algorithm |
|
|
1111 | (5) |
|
|
|
1116 | (2) |
|
Focus on Software Engineering: Recursion vs. Iteration |
|
|
1118 | (7) |
|
|
|
1125 | (26) |
|
Definition and Applications of Binary Trees |
|
|
1125 | (3) |
|
Binary Search Tree Operations |
|
|
1128 | (17) |
|
Template Considerations for Binary Search Trees |
|
|
1145 | (6) |
| Appendix A: The ASCII Character Set |
|
1151 | (4) |
| Appendix B: Operator Precedence and Associativity |
|
1155 | (2) |
| Index |
|
1157 | |