search for books and compare prices
Tables of Contents for Absolute C++ Codemate
Chapter/Section Title
Page #
Page Count
Chapter 1 C++ Basics
1
42
1.1 INTRODUCTION TO C++
2
4
Origins of the C++ Language
2
1
C++ and Object-Oriented Programming
3
1
The Character of C++
3
1
C++ Terminology
4
1
A Sample C++ Program
4
2
1.2 VARIABLES, EXPRESSIONS, AND ASSIGNMENT STATEMENTS
6
22
Identifiers
6
2
Variables
8
2
Assignment Statements
10
2
PITFALL Uninitialized Variables
12
1
TIP Use Meaningful Names
13
9
More Assignment Statements
13
1
Assignment Compatibility
14
1
Literais
15
2
Escape Sequences
17
1
Naming Constants
17
2
Arithmetic Operators and Expressions
19
2
Integer and Floating-Point Division
21
1
PITFALL Division with Whole Numbers
22
5
Type Casting
23
2
Increment and Decrement Operators
25
2
PITFALL Order of Evaluation
27
1
1.3 CONSOLE INPUT/OUTPUT
28
7
Output Using cont
28
1
New Lines in Output
29
1
TIP End Each Program with \n or end l
30
4
Formatting for Numbers with a Decimal Point
30
2
Output with cerr
32
1
Input Using do
32
2
TIP Line Breaks in I/O
34
1
1.4 PROGRAM STYLE
35
1
Comments
35
1
1.5 LIBRARIES AND NAMESPACES
36
2
Libraries and include Directives
36
1
Namespaces
37
1
PITFALL Problems with Library Names
38
1
CHAPTER SUMMARY
38
1
ANSWERS TO SELF-TEST EXERCISES
39
2
PROGRAMMING PROJECTS
41
2
Chapter 2 Flow of Control
43
48
2.1 BOOLEAN EXPRESSIONS
44
10
Building Boolean Expressions
44
1
PITFALL Strings of Inequalities
45
7
Evaluating Boolean Expressions
46
2
Precedence Rules
48
4
PITFALL Integer Values Can Be Used as Boolean Values
52
2
2.2 BRANCHING MECHANISMS
54
12
if-else Statements
54
2
Compound Statements
56
1
PITFALL Using = in Place of ==
57
6
Omitting the else
58
1
Nested Statements
59
1
Multiway if-else Statement
59
2
The switch Statement
61
2
PITFALL Forgetting a break in a switch Statement
63
1
TIP Use switch Statements for Menus
63
3
Enumeration Types
64
1
The Conditional Operator
64
2
2.3 LOOPS
66
17
The while and do-while Statements
66
3
Increment and Decrement Operators Revisited
69
3
The Comma Operator
72
1
The for Statement
73
3
TIP Repeat-N-Times loops
76
1
PITFALL Extra Semicolon in a for Statement
76
1
PITFALL Infinite Loops
77
26
The break and continue Statements
80
3
Nested loops
83
1
CHAPTER SUMMARY
83
1
ANSWERS TO SELF-TEST EXERCISES
84
5
PROGRAMMING PROJECTS
89
2
Chapter 3 Function Basics
91
42
3.1 PREDEFINED FUNCTIONS
92
11
Predefined Functions That Return a Value
92
5
Predefined void Functions
97
2
A Random Number Generator
99
4
3.2 PROGRAMMER-DEFINED FUNCTIONS
103
14
Defining Functions That Return a Value
103
3
Alternate Form for Function Declarations
106
1
PITFALL Arguments in the Wrong Order
107
1
PITFALL Use of the Terms Parameter and Argument
107
1
Functions Calling Functions
107
1
EXAMPLE A Rounding Function
107
10
Functions That Return a Boolean Value Bio Defining void Functions
111
1
Return Statements in void Functions
112
1
Preconditions and Postconditions
113
2
Main Is a Function
115
1
Recursive Functions
116
1
3.3 SCOPE RULES
117
9
Local Variables
117
3
Procedural Abstraction
120
1
Global Constants and Global Variables
121
3
Blocks
124
1
Nested Scopes
124
1
TIP Use Function Calls in Branching and Loop Statements
125
9
Variables Declared in a for Loop
125
1
CHAPTER SUMMARY
126
1
ANSWERS TO SELF-TEST EXERCISES
127
3
PROGRAMMING PROJECTS
130
3
Chapter 4 Parameters and Overloading
133
38
4.1 PARAMETERS
134
17
Call-by-Value Parameters
134
3
A First Look at Call-by-Reference Parameters
137
2
Call-by-Reference Mechanism in Detail
139
2
EXAMPLE The swapValues Function
141
2
Constant Reference Parameters
142
1
TIP Think of Actions, Not Code
143
2
Mixed Parameter Lists
144
1
TIP What Kind of Parameter to Use
145
1
PITFALL Inadvertent Local Variables
146
1
TIP Choosing Formal Parameter Names
147
1
EXAMPLE Buying Pizza
147
4
4.2 OVERLOADING AND DEFAULT ARGUMENTS
151
10
Introduction to Overloading
151
3
PITFALL Automatic Type Conversion and Overloading
154
3
Rules for Resolving Overloading
156
1
EXAMPLE Revised Pizza-Buying Program
157
15
Default Arguments
159
2
4.3 TESTING AND DEBUGGING FUNCTIONS
161
4
The assert Macro
161
1
Stubs and Drivers
162
3
CHAPTER SUMMARY
165
1
ANSWERS TO SELF-TEST EXERCISES
166
2
PROGRAMMING PROJECTS
168
3
Chapter 5 Arrays
171
52
5.1 INTRODUCTION TO ARRAYS
172
9
Declaring and Referencing Arrays
172
3
TIP Use for Loops with Arrays
175
1
PITFALL Array Indexes Always Start with Zero
175
1
TIP Use a Defined Constant for the Size of an Array
175
2
Arrays in Memory
176
1
PITFALL Array Index Out of Range
177
4
Initializing Arrays
178
3
5.2 ARRAYS IN FUNCTIONS
181
13
Indexed Variables as Function Arguments
181
1
Entire Arrays as Function Arguments
182
3
The const Parameter Modifier
185
2
PITFALL Inconsistent Use of const Parameters
187
1
Functions That Return an Array
188
1
EXAMPLE Production Graph
188
6
5.3 PROGRAMMING WITH ARRAYS
194
10
Partially Filled Arrays
194
1
TIP Do Not Skimp on Formal Parameters
194
3
EXAMPLE Searching an Array
197
2
EXAMPLE Sorting an Array
199
5
5.4 MULTIDIMENSIONAL ARRAYS
204
7
Multidimensional Array Basics
204
1
Multidimensional Array Parameters
205
2
EXAMPLE Two-Dimensional Grading Program
207
4
CHAPTER SUMMARY
211
1
ANSWERS TO SELF-TEST EXERCISES
212
4
PROGRAMMING PROJECTS
216
7
Chapter 6 Structures and Classes
223
34
6.1 STRUCTURES
224
12
Structure Types
226
4
PITFALL Forgetting a Semicolon in a Structure Definition
230
1
Structures as Function Arguments
230
1
TIP Use Hierarchical Structures
231
5
Initializing Structures
234
2
6.2 CLASSES
236
16
Defining Classes and Member Functions
236
6
Encapsulation
242
1
Public and Private Members
243
4
Accessor and Mutator Functions
247
1
TIP Separate Interface and Implementation
248
1
TIP A Test for Encapsulation
249
3
Structures versus Classes
250
2
TIP Thinking Objects
252
1
CHAPTER SUMMARY
252
1
ANSWERS TO SELF-TEST EXERCISES
253
2
PROGRAMMING PROJECTS
255
2
Chapter 7 Constructors and Other Tools
257
44
7.1 CONSTRUCTORS
258
19
Constructor Definitions
258
5
PITFALL Constructors with No Arguments
263
2
Explicit Constructor Calls
265
1
TIP Always Include a Default Constructor
265
3
EXAMPLE Bank Account Class
268
9
Class Type Member Variables
274
3
7.2 MORE TOOLS
277
13
The const Parameter Modifier
277
2
PITFALL Inconsistent Use of const
279
11
Inline Functions
284
2
Static Members
286
3
Nested and Local Class Definitions
289
1
7.3 VECTORS-A PREVIEW OF THE STANDARD TEMPLATE LIBRARY
290
6
Vector Basics
290
3
PITFALL Using Square Brackets beyond the Vector Size
293
1
TIP Vector Assignment Is Well Behaved
294
8
Efficiency Issues
294
2
CHAPTER SUMMARY
296
1
ANSWERS TO SELF-TEST EXERCISES
296
2
PROGRAMMING PROJECTS
298
3
Chapter 8 Operator Overloading, Friends, and References
301
48
8.1 BASIC OPERATOR OVERLOADING
302
16
Overloading Basics
303
5
TIP A Constructor Can Return an Object
308
4
Returning by const Value
309
3
TIP Returning Member Variables of a Class Type
312
4
Overloading Unary Operators
313
1
Overloading as Member Functions
314
2
TIP A Class Has Access to All Its Objects
316
1
Overloading Function Application ( )
317
1
PITFALL Overloading &&,||, and the Comma Operator
317
1
8.2 FRIEND FUNCTIONS AND AUTOMATIC TYPE CONVERSION
318
6
Constructors for Automatic Type Conversion
318
1
PITFALL Member Operators and Automatic Type Conversion
319
4
Friend Functions
320
3
PITFALL Compilers without Friends
323
1
Friend Classes
323
1
8.3 REFERENCES AND MORE OVERLOADED OPERATORS
324
18
References
325
2
PITFALL Returning a Reference to Certain Member Variables
327
8
Overloading » and «
327
8
TIP What Mode of Returned value to Use
335
16
The Assignment Operator
336
1
Overloading the Increment and Decrement Operators
337
1
Overloading the Array Operator []
337
4
Overloading Based on L-Value versus R-Value
341
1
CHAPTER SUMMARY
342
1
ANSWERS TO SELF-TEST EXERCISES
342
3
PROGRAMMING PROJECTS
345
4
Chapter 9 Strings
349
54
9.1 AN ARRAY TYPE FOR STRINGS
351
12
C-String Values and C-String Variables
351
4
PITFALL Using = and == with C-strings
355
8
Other Functions in "cstring"
357
3
C-String Input and Output
360
3
9.2 CHARACTER MANIPULATION TOOLS
363
12
Character I/O
363
1
The Member Functions get and put
364
2
EXAMPLE Checking Input Using a Newline Function
366
2
PITFALL Unexpected '\n' in Input
368
6
The putback, peek, and ignore Member Functions
369
3
Character-Manipulating Functions
372
2
PITFALL toupper and tolower Return int Values
374
1
9.3 THE STANDARD CLASS string
375
18
Introduction to the Standard Class string
376
3
I/O with the Class string
379
3
TIP More Versions of getline
382
1
PITFALL Mixing cin variable; and getline
383
5
String Processing with the Class string
384
4
EXAMPLE Palindrome Testing
388
16
Converting between string Objects and C-Strings
392
1
CHAPTER SUMMARY
393
1
ANSWERS TO SELF-TEST EXERCISES
393
4
PROGRAMMING PROJECTS
397
6
Chapter 10 Pointers and Dynamic Arrays
403
54
10.1 POINTERS
404
18
Pointer Variables
405
9
Basic Memory Management
414
2
PITFALL Dangling Pointers
416
1
Dynamic Variables and Automatic Variables
416
1
TIP Define Pointer Types
417
2
PITFALL Pointers as Call-by-Value Parameters
419
3
Uses for Pointers
421
1
10.2 DYNAMIC ARRAYS
422
11
Array Variables and Pointer Variables
422
1
Creating and Using Dynamic Arrays
423
4
EXAMPLE A Function That Returns an Array
427
6
Pointer Arithmetic
429
1
Multidimensional Dynamic Arrays
430
3
10.3 CLASSES, POINTERS, AND DYNAMIC ARRAYS
433
18
The "arrow" Operator
433
1
The this Pointer
434
1
Overloading the Assignment Operator
435
2
EXAMPLE A Class for Partially Filled Arrays
437
21
Destructors
445
1
Copy Constructors
446
5
CHAPTER SUMMARY
451
1
ANSWERS TO SELF-TEST EXERCISES
452
2
PROGRAMMING PROJECTS
454
3
Chapter 11 Separate Compilation and Namespaces
457
42
11.1 SEPARATE COMPILATION
458
15
Encapsulation Reviewed
459
1
Header Files and Implementation Files
460
8
EXAMPLE DigitalTime Class
468
1
TIP Reusable Components
469
3
Using #ifndef
469
3
TIP Defining Other Libraries
472
1
11.2 NAMESPACES
473
22
Namespaces and using Directives
473
2
Creating a Namespace
475
3
Using Declarations
478
2
Qualifying Names
480
2
EXAMPLE A Class Definition in a Namespace
482
1
TIP Choosing a Name for a Namespace
482
8
Unnamed Namespaces
484
6
PITFALL Confusing the Global Namespace and the Unnamed Namespace
490
1
TIP Unnamed Namespaces Replace the static Qualifier
491
1
TIP Hiding Helping Functions
491
1
Nested Namespaces
491
1
TIP What Namespace Specification Should You Use?
492
3
CHAPTER SUMMARY
495
1
ANSWERS TO SELF-TEST EXERCISES
495
2
PROGRAMMING PROJECTS
497
2
Chapter 12 Streams and File I/O
499
48
12.1 I/O STREAMS
501
16
File I/O
501
5
PITFALL Restrictions on Stream Variables
506
2
Appending to a File
506
2
TIP Another Syntax for Opening a File
508
1
TIP Check That a File Was Opened Successfully
509
8
Character I/O
512
1
Checking for the End of a File
513
4
12.2 TOOLS FOR STREAM I/O
517
11
File Names as Input
517
1
Formatting Output with Stream Functions
518
3
Manipulators
521
2
Saving Flag Settings
523
1
More Output Stream Member Functions
524
1
EXAMPLE Cleaning Up a File Format
525
3
EXAMPLE Editing a Text File
528
1
12.3 STREAM HIERARCHIES: A PREVIEW OF INHERITANCE
528
8
Inheritance among Stream Classes
528
5
EXAMPLE Another newLine Function
533
3
12.4 Random Access to Files
536
2
CHAPTER SUMMARY
538
1
ANSWERS TO SELF-TEST EXERCISES
539
2
PROGRAMMING PROJECTS
541
6
Chapter 13 Recursion
547
36
13.1 RECURSIVE VOID FUNCTIONS
549
12
EXAMPLE Vertical Numbers
549
7
Tracing a Recursive Call
552
3
A Closer Look at Recursion
555
1
PITFALL Infinite Recursion
556
3
Stacks for Recursion
558
1
PITFALL Stack Overflow
559
2
Recursion versus Iteration
559
2
13.2 RECURSIVE FUNCTIONS THAT RETURN A VALUE
561
5
General Form for a Recursive Function That Returns a Value
561
1
EXAMPLE Another Powers Function
561
5
13.3 THINKING RECURSIVELY
566
10
Recursive Design Techniques
566
2
Binary Search
568
8
CHAPTER SUMMARY
576
1
ANSWERS TO SELF-TEST EXERCISES
576
5
PROGRAMMING PROJECTS
581
2
Chapter 14 Inheritance
583
44
14.1 INHERITANCE BASICS
584
22
Derived Classes
584
10
Constructors in Derived Classes
594
2
PITFALL use of Private Member variables from the Base Class
596
2
PITFALL Private Member Functions Are Effectively Not Inherited
598
8
The protected Qualifier
598
3
Redefinition of Member Functions
601
2
Redefining versus Overloading
603
1
Access to a Redefined Base Function
604
1
Functions That Are Not Inherited
605
1
14.2 PROGRAMMING WITH INHERITANCE
606
17
Assignment Operators and Copy Constructors in Derived Classes
606
1
Destructors in Derived Classes
607
1
EXAMPLE Partially Filled Array with Backup
608
9
PITFALL Same Object on Both Sides of the Assignment Operator
617
1
EXAMPLE Alternate Implementation of PFArrayDBak
617
1
TIP A Class Has Access to Private Members of All Objects of the Class
618
2
TIP Is a" versus "Has a"
620
8
Protected and Private Inheritance
621
1
Multiple Inheritance
622
1
CHAPTER SUMMARY
623
2
ANSWERS TO SELF-TEST EXERCISES 623 PROGRAMMING PROJECTS
625
2
Chapter 15 Polymorphism and Virtual Functions
627
26
15.1 VIRTUAL FUNCTION BASICS
628
13
Late Binding
628
1
Virtual Functions in C++
629
7
TIP The Virtual Property Is Inherited
636
1
TIP When to Use a Virtual Function
636
1
PITFALL Omitting the Definition of a Virtual Member Function
637
1
Abstract Classes and Pure Virtual Functions
637
1
EXAMPLE An Abstract Class
638
3
15.2 POINTERS AND VIRTUAL FUNCTIONS
641
9
Virtual Functions and Extended Type Compatibility
641
4
PITFALL The Slicing Problem
645
1
TIP Make Destructors Virtual
646
8
Downcasting and Upcasting
647
2
How C++ Implements Virtual Functions
649
1
CHAPTER SUMMARY
650
1
ANSWERS TO SELF-TEST EXERCISES
651
1
PROGRAMMING PROJECTS
651
2
Chapter 16 Templates
653
36
16.1 FUNCTION TEMPLATES
654
13
Syntax for Function Templates
656
3
PITFALL Compiler Complications
659
2
EXAMPLE A Generic Sorting Function
661
4
TIP How to Define Templates
665
1
PITFALL Using a Template with an Inappropriate Type
665
2
16.2 CLASS TEMPLATES
667
11
Syntax for Class Templates
667
4
EXAMPLE An Array Template Class
671
7
The vector and basic_string Templates
677
1
16.3 TEMPLATES AND INHERITANCE
678
6
EXAMPLE Template Class for a Partially Filled Array with Backup
678
6
CHAPTER SUMMARY
684
1
ANSWERS TO SELF-TEST EXERCISES
684
4
PROGRAMMING PROJECTS
688
1
Chapter 17 Linked Data Structures
689
68
17.1 NODES AND LINKED LISTS
691
24
Nodes
691
5
Linked Lists
696
2
Inserting a Node at the Head of a List
698
2
PITFALL Losing Nodes
700
6
Inserting and Removing Nodes Inside a List
702
4
PITFALL Using the Assignment Operator with Dynamic Data Structures
706
5
Searching a Linked List
706
5
EXAMPLE Template Version of Linked List Tools
711
4
17.2 LINKED LIST APPLICATIONS
715
14
EXAMPLE A Stack Template Class
715
7
EXAMPLE A Queue Template Class
722
3
TIP A Comment on Namespaces
725
4
Friend Classes and Similar Alternatives
726
3
17.3 ITERATORS
729
9
Pointers as Iterators
729
1
Iterator Classes
730
1
EXAMPLE An Iterator Class
731
7
17.4 TREES
738
11
Tree Properties
739
3
EXAMPLE A Tree Template Class
742
7
CHAPTER SUMMARY
749
 
ANSWERS TO SELF-TEST EXERCISES
747
7
PROGRAMMING PROJECTS
754
3
Chapter 18 Exception Handling
757
30
18.1 EXCEPTION HANDLING BASICS
759
20
A Toy Example of Exception Handling
759
9
Defining Your Own Exception Classes
768
1
Multiple Throws and Catches
768
4
PITFALL Catch the More Specific Exception First
772
1
TIP Exception Classes Can Be Trivial
773
4
Throwing an Exception in a Function
773
2
Exception Specification
775
2
PITFALL Exception Specification in Derived Classes
777
2
18.2 PROGRAMMING TECHNIQUES FOR EXCEPTION HANDLING
779
5
When to Throw an Exception
779
2
PITFALL Uncaught Exceptions
781
1
PITFALL Nested try-catch Blocks
781
1
PITFALL Overuse of Exceptions
782
7
Exception Class Hierarchies
782
1
Testing for Available Memory
782
1
Rethrowing an Exception
783
1
CHAPTER SUMMARY
784
1
ANSWERS TO SELF-TEST EXERCISES
784
1
PROGRAMMING PROJECTS
785
2
Chapter 19 Standard Template Library
787
50
19.1 ITERATORS
789
14
Iterator Basics
789
6
Kinds of Iterators
795
3
Constant and Mutable Iterators
798
2
Reverse Iterators
800
2
PITFALL Compiler Problems
802
1
Other Kinds of Iterators
802
1
19.2 CONTAINERS
803
14
Sequential Containers
803
5
PITFALL Iterators and Removing Elements
808
1
TIP Type Definitions in Containers
808
30
The Container Adapters stack and queue
809
1
The Associative Containers set and map
810
5
Efficiency
815
2
19.3 GENERIC ALGORITHMS
817
14
Running Times and Big-o Notation
818
4
Container Access Running Times
822
1
Nonmodifying Sequence Algorithms
823
5
Modifying Sequence Algorithms
828
1
Set Algorithms
828
1
Sorting Algorithms
829
2
CHAPTER SUMMARY
831
1
ANSWERS TO SELF-TEST EXERCISES
832
1
PROGRAMMING PROJECTS
833
4
Chapter 20 Patterns and UML
837
18
20.1 PATTERNS
838
11
Adapter Pattern
839
1
The Model-View-Controller Pattern
839
2
EXAMPLE A Sorting Pattern
841
6
Efficiency of the Sorting Pattern
845
2
TIP Pragmatics and Patterns
847
2
Pattern Formalism
848
1
20.2 UML
849
2
History of UML
849
1
UML Class Diagrams
850
1
Class Interactions
850
1
CHAPTER SUMMARY
851
1
ANSWERS TO SELF-TEST EXERCISES
851
2
PROGRAMMING PROJECTS
853
2
Appendix 1 C++ Keywords
855
2
Appendix 2 Precedence of Operators
857
2
Appendix 3 The ASCII Character Set
859
2
Appendix 4 Some Library Functions
861
8
Arithmetic Functions
861
1
Input and Output Member Functions
862
1
Character Functions
863
1
C-String Functions
864
2
string Class Functions
866
1
Random Number Generator
867
1
Trigonometric Functions
868
1
Appendix 5 Old and New Header Files
869
2
Further Reading
871
2
Index
873