Tải bản đầy đủ (.pdf) (7 trang)

a0015 c object oriented programmin morebook vn 2822

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (156.06 KB, 7 trang )

ABC Amber CHM Converter Trial version, />
Waite Group's Object-Oriented Programming in C++, Third Edition
(Publisher: Macmillan Computer Publishing)
Author(s): Robert Lafore
ISBN: 157169160x
Publication Date: 11/25/98
Bottom of Form

Previous Table of Contents

Next

Preface
The major changes to this Third Edition are concerned with Standard C++ and object-oriented design. In
addition, the book is no longer geared exclusively to Borland C++ compilers.
Standard C++, finalized in the fall of 1997, introduced many new features to C++. Some of these features,
such as templates and exceptions, had already been adopted by compiler manufacturers. However, the
Standard Template Library (STL) has only recently been included in compilers. This book adds a chapter
on the STL.
We’ve also introduced other features from Standard C++, including new header files, the string class,
new-style casts, namespaces, and so on.
The design of object-oriented programs has received increasing emphasis in recent years, so we’ve added
a chapter on object-oriented design.
The advent of Standard C++ means that, at least to a greater extent than before, all compilers should treat
source code in the same way. Accordingly, we’ve modified our emphasis on Borland compilers, and now
focus on code that should work with any Standard C++ compiler. Of course, the reality seldom matches
the ideal, so so the programs in this book have been tested with both Microsoft and Borland compilers,
and modified when necessary to work with both of them.

Previous Table of Contents


Next

Page 1


ABC Amber CHM Converter Trial version, />
Waite Group's Object-Oriented Programming in C++, Third Edition
(Publisher: Macmillan Computer Publishing)
Author(s): Robert Lafore
ISBN: 157169160x
Publication Date: 11/25/98
Bottom of Form

Previous Table of Contents

Next

About the Author
Robert Lafore has been writing books about computer programming since 1982. His best-selling titles
include Assembly Language Programming for the IBM PC, C Programming Using Turbo C++, C++
Interactive Course, and Data Structures and Algorithms in Java. Mr. Lafore holds degrees in
mathematics and electrical engineering, and has been active in programming since the days of the PDP-5,
when 4K of main memory was considered luxurious. His interests include hiking, windsurfing, and
recreational mathematics.

Acknowledgments to the Third Edition
I’d like to thank the entire team at Macmillan Computer Publishing. In particular, Tracy Dunkelberger
ably spearheaded the entire project and exhibited great patience with what turned out to be a lengthy
schedule. Jeff Durham handled the myriad details involved in interfacing between me and the editors with
skill and good humor. Andrei Kossorouko lent his expertise in C++ to ensure that I didn’t make this

edition worse instead of better.

Acknowledgments to the Second Edition
My thanks to the following professor—susers of this book as a text at their respective colleges and
universities—for their help in planning the second edition: Dave Bridges, Frank Cioch, Jack Davidson,
Terrence Fries, Jimmie Hattemer, Jack Van Luik, Kieran Mathieson, Bill McCarty, Anita Millspaugh, Ian
Moraes, Jorge Prendes, Steve Silva, and Edward Wright.
I would like to thank the many readers of the first edition who wrote in with corrections and suggestions,
many of which were invaluable.
At Waite Group Press, Joanne Miller has ably ridden herd on my errant scheduling and filled in as
academic liaison, and Scott Calamar, as always, has made sure that everyone knew what they were
doing. Deirdre Greene provided an uncannily sharp eye as copy editor.
Thanks, too, to Mike Radtke and Harry Henderson for their expert technical reviews.
Special thanks to Edward Wright, of Western Oregon State College, for reviewing and experimenting
with the new exercises.

Acknowledgments to the First Edition
My primary thanks go to Mitch Waite, who poured over every inch of the manuscript with painstaking
attention to detail and made a semi-infinite number of helpful suggestions.
Bill McCarty of Azusa Pacific University reviewed the content of the manuscript and its suitability for
classroom use, suggested many excellent improvements, and attempted to correct my dyslexic spelling.

Page 2


ABC Amber CHM Converter Trial version, />
George Leach ran all the programs, and, to our horror, found several that didn’t perform correctly in
certain circumstances. I trust these problems have all been fixed; if not, the fault is entirely mine.
Scott Calamar of The Waite Group dealt with the myriad organizational aspects of writing and producing
this book. His competence and unfailing good humor were an important ingredient in its completion.

I would also like to thank Nan Borreson of Borland for supplying the latest releases of the software
(among other useful tidbits), Harry Henderson for reviewing the exercises, Louise Orlando of The Waite
Group for ably shepherding the book through production, Merrill Peterson of Matrix Productions for
coordinating the most trouble-free production run I’ve ever been involved with, Juan Vargas for the
innovative design, and Frances Hasegawa for her uncanny ability to decipher my sketches and produce
beautiful and effective art.

Dedication
This book is dedicated to GGL another inodomitable spirit.222

Tell Us What You Think!
As the reader of this book, you are our most important critic and commentator. We value your opinion
and want to know what we’re doing right, what we could do better, what areas you’d like to see us
publish in, and any other words of wisdom you’re willing to pass our way.
As the Executive Editor for the Advanced Programming and Distributed Architectures team at Macmillan
Computer Publishing, I welcome your comments. You can fax, email, or write me directly to let me know
what you did or didn’t like about this book—as well as what we can do to make our books stronger.
Please note that I cannot help you with technical problems related to the topic of this book, and
that due to the high volume of mail I receive, I might not be able to reply to every message.
When you write, please be sure to include this book’s title and author as well as your name and phone or
fax number. I will carefully review your comments and share them with the author and editors who
worked on the book.
Fax:
317-817-7070
Email:
Mail: Tracy Dunkelberger
Executive Editor
Advanced Programming and Distributed Architectures
Macmillan Computer Publishing
201 West 103rd Street

Indianapolis, IN 46290 USA

Previous Table of Contents

Next

Page 3


ABC Amber CHM Converter Trial version, />
Waite Group's Object-Oriented Programming in C++, Third Edition
(Publisher: Macmillan Computer Publishing)
Author(s): Robert Lafore
ISBN: 157169160x
Publication Date: 11/25/98
Bottom of Form

Previous Table of Contents

Next

APPENDIX A
ASCII Chart
Table A.1 IBM Character Codes
DEC
HEX
Symbol
0
00
(NULL)

1
01
A
2
02
B
3
03
C
4
04
D
5
05
E
6
06
F
7
07
G
8
08
H
9
09
I
10
0A
J

11
0B
K
12
0C
L
13
0D
M
14
0E
N
15
0F
O
16
10
P
17
11
Q
18
12
R
19
13
S
20
14
T

21
15
U
22
16
_
23
17
W
24
18
X
25
19
Y
26
1A
Z
27
1B
a

Key
Ctrl 2
Ctr A
Ctrl B
Ctrl C
Ctrl B
Ctrl E
Ctrl F

Ctrl G
Backspace
Tab
Ctrl J
Ctrl K
Ctrl L
Enter
Ctrl N
Ctrl O
Ctrl P
Ctrl Q
Ctrl R
Ctrl S
Ctrl T
Ctrl U
Ctrl V
Ctrl W
Ctrl X
Ctrl Y
Ctrl Z
Escape

Use in C

Beep
Backspace
Tab
Linefeed (new line)
Vertical Tab
Form Feed

Carriage Return

Page 4


ABC Amber CHM Converter Trial version, />
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51

52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67

1C
1D
1E
1F
20
21
22
23
24
25
26
27
28

29
2A
2B
2C
2D
2E
2F
30
31
32
33
34
35
36
37
38
39
3A
3B
3C
3D
3E
3F
40
41
42
43

b
c

d
e

!

#
$
%
&

(
)
*
+
,

.
/
0
1
2
3
4
5
6
7
8
9
:
;

<
=
>
?
@
A
B
C

Ctrl \
Ctrl ]
Ctrl 6
Ctrl –
SPACE BAR
!

#
$
%
&

(
)
*
+
,

.
/
0

1
2
3
4
5
6
7
8
9
:
;
<
=
>
?
@
A
B
C

Page 5


ABC Amber CHM Converter Trial version, />
Teachers, and others who already know C, may be interested in some details of the approach we use in
this book and how it’s organized.
Standard C++
We’ve revised all the programs in this book to make them compatible with Standard C++. This involved, at
a minimum, changes to header files, the addition of namespace designation, and making return type . Many
programs received more extensive modifications, including the substitution in many places of the new class

for the old C-style strings.
We devote a new chapter to the STL (Standard Template Library), which is now included in Standard C
++.
Object-Oriented Design
Students are frequently mystified by the process of breaking a programming project into appropriate
classes. For this reason we’ve added a chapter on object-oriented design. This chapter is placed near the
end of the book, but we encourage students to skim it earlier to get the flavor of OOD. Of course, small
programs don’t require such a formal design approach, but it’s helpful to know what’s involved even when
designing programs in your head. C++ is not the same as C.
Some institutions want their students to learn C before learning C++. In our view this is a mistake. C and C
++ are entirely separate languages. It’s true that their syntax is similar, and C is actually a subset of C++.
But the similarity is largely a historical accident. In fact, the basic approach in a C++ program is radically
different from that in a C program.
C++ has overtaken C as the preferred language for serious software development. Thus we don’t believe it
is necessary or advantageous to teach C before teaching C++. Students who don’t know C are saved the
time and trouble of learning C and then learning C++, an inefficient approach. Students who already know
C may be able to skim parts of some chapters, but they will find that a remarkable percentage of the
material is new.
Optimize Organization for OOP
We could have begun the book by teaching the procedural concepts common to C and C++, and moved
on to the new OOP concepts once the procedural approach had been digested. That seemed
counterproductive, however, because one of our goals is to begin true Object-Oriented Programming as
quickly as possible. Accordingly, we provide a minimum of procedural groundwork before getting to
objects in Chapter 7. Even the initial chapters are heavily steeped in C++, as opposed to C, usage.
We introduce some concepts earlier than is traditional in books on C. For example, structures are a key
feature for understanding C++ because classes are syntactically an extension of structures. For this reason,
we introduce structures in Chapter 5 so that they will be familiar when we discuss classes.
Some concepts, such as pointers, are introduced later than in traditional C books. It’s not necessary to
understand pointers to follow the essentials of OOP, and pointers are usually a stumbling block for C and
C++ students. Therefore, we defer a discussion of pointers until the main concepts of OOP have been

thoroughly digested.
Substitute Superior C++ Features
Some features of C have been superseded by new approaches in C++. For instance, the and functions,
input/output workhorses in C, are seldom used in C++ because and do a better job. Consequently, we

Page 987


ABC Amber CHM Converter Trial version, />
leave out descriptions of these functions. Similarly, constants and macros in C have been largely
superseded by the qualifier and inline functions in C++, and need be mentioned only briefly.
Minimize Irrelevant Capabilities
Because the focus in this book is on Object-Oriented Programming, we can leave out some features of C
that are seldom used and are not particularly relevant to OOP. For instance, it isn’t necessary to
understand the C bit-wise operators (used to operate on individual bits) to learn Object-Oriented
Programming. These and a few other features can be dropped from our discussion, or mentioned only
briefly, with no loss in understanding of the major features of C++.
The result is a book that focuses on the fundamentals of OOP, moving the reader gently but briskly toward
an understanding of new concepts and their application to real programming problems.

Programming Examples
There are numerous listings of code scattered throughout the book that you will want to try out for
yourself. The program examples are available for download by going to Macmillan Computer Publishing’s
web site, and go to this book’s page by entering the ISBN and
clicking Search. To download the programming examples, just click the appropriate link on the page.

Programming Exercises
One of the major changes in the second edition was the addition of numerous exercises. Each of these
involves the creation of a complete C++ program. There are roughly 12 exercises per chapter. Solutions to
the first three or four exercises in each chapter are provided in Appendix D. For the remainder of the

exercises, readers are on their own, although qualified instructors can suggested solutions. Please visit
Macmillan Computer Publishing’s Web site, and go to this book’s
page by entering the ISBN and clicking Search. Click on the appropriate link to receive instructions on
downloading the encrypted files and decoding them.
The exercises vary considerably in their degree of difficulty. In each chapter the early exercises are fairly
easy, while later ones are more challenging. Instructors will probably want to assign only those exercises
suited to the level of a particular class.

Previous Table of Contents

Next

Page 988



×