文档介绍:Algorithms,
Data Structures, and
Problem Solving with C++
by Mark Allen Weiss
Transparency Masters
Visit the web site for this book at:
ng/authors/weiss/adp-cpp
A
List of Transparencies
Chapter 1 Pointers, Arrays, and Structures 1
Pointer illustration 2
Result of *Ptr=10 3
Uninitialized pointer 4
(a) Initial state; (b) Ptr1=Ptr2 starting from initial state; (c) *Ptr1=*Ptr2 starting from
initial state 5
Memory model for arrays (assumes 4 byte int); declaration is int A[3]; int i; 6
Some of the string routines in <> 7
Two ways to allocate arrays; one leaks memory 8
Memory reclamation 9
Array expansion: (a) starting point: A2 points at 10 integers; (b) after step 1: Original
points at the 10 integers; (c) after steps 2 and 3: A2 points at 12 integers, the first 10
of which are copied from Original; (d) after step 4: the 10 integers are freed 10
Pointer arithmetic: X=&A[3]; Y=X+4 11
First eight lines from prof for program 12
First eight lines from prof with highest optimization 12
Student structure 13
Illustration of a shallow copy in which only pointers are copied 14
Illustration of a simple linked list 15
Chapter 2 Objects and Classes 16
plete declaration of a MemoryCell class 17
MemoryCell members: Read and Write are accessible, but StoredValue is hidden
18
A simple test routine to show how MemoryCell objects are accessed 19
A more typical MemoryCell declaration in which interface and implementation are sepa-
rated 20
Interface for BitArray class 21
Copyright 1996 by Addison-Wesley pany ii
BitArray members 22
Construction examples 23
Chapter 3 Templates 24
Basic action of insertion sort (shaded part is sorted) 25
Closer look at action of insertion sort (dark shading indicates sorted area; light shading is where
new element was placed) 26
Typical layout for template interface and member functions 27
Chapter 4 Inheritance 28
General layout of public inheritance 29
Access rules that depend on wh