Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:

lafore_robert_objectoriented_programming_in_c

.pdf
Скачиваний:
47
Добавлен:
27.03.2023
Размер:
8.94 Mб
Скачать

Answers to Questions and Exercises

7.generalization, association, aggregation

8.a, d

9.false

10.a

11.true

12.false

13.a, b, c, d

14.people (or human beings), other systems, program (or system)

15.b

16.b, c

17.false

18.a, d

19.b, d

20.false

21.c, d

22.object

23.true

24.a, d

975

G

Q E UESTIONS ANSWERS XERCISES AND TO

Bibliography

A PPENDI X

H

IN THIS APPENDIX

• Advanced C++

978

 

• Defining Documents

978

• The Unified Modeling Language 978

The History of C++

979

Other Topics

979

 

Appendix H

978

This appendix lists some books that might prove useful or interesting to students of C++.

Advanced C++

After you’ve mastered the fundamentals of C++, the next books you should probably buy are Effective C++, by Scott Meyers (Addison Wesley, 1997), and More Effective C++, also by Scott Meyers (Addison Wesley, 1996). These books contain, respectively, “50 specific ways to improve your programs and designs” and “35 new ways to improve your programs and designs.” Each of the topics in these books is short but clearly presented. These books provide a wealth of important ideas and are widely read by C++ programmers.

Thinking in C++ by Bruce Eckel (Prentice Hall, 1995) is probably a little too fast for beginners, but it covers the fundamentals of the language and is excellent at explaining why things work the way they do.

C++ FAQs (Frequently Asked Questions) by Marshall Cline and Greg Lomow (Addison Wesley, 1995) contains hundreds of topics about C++ in short question-and-answer format. It’s easy reading and will contribute to your understanding of C++.

C++ Distilled by Ira Pohl (Addison Wesley, 1997) is a short summary of the important features of C++. It’s great if you’ve forgotten a particular syntax and want to look it up in a hurry.

Defining Documents

Because the author is the language’s creator, the most definitive text on C++ is The C++ Programming Language, Third Edition by Bjarne Stroustrup (Addison Wesley, 1997). Every serious C++ programmer should have a copy of this book. It assumes a certain level of sophistication, so it’s not for beginners. However, it’s clearly written, and once you’ve mastered the fundamentals it’s an invaluable aid to the finer points of C++ usage.

You probably won’t need the actual defining document for Standard C++ until you’ve progressed quite far in your study of C++. The Final Draft Information Standard (FDIS) for the C++ Programming Language, X3J16/97-14882, is available from the Information Technology Council (NSTIC), Washington, D.C.

The previous defining document on C++ was The Annotated C++ Reference Manual by Margaret Ellis and Bjarne Stroustrup (Addison Wesley, 1990). This is fairly heavy going and filled with arcane explanations. It’s also out of date.

The Unified Modeling Language

Addison Wesley seems to have cornered the market in UML books: they are the publishers for all the titles we list here. The first two are by Grady Booch, James Rumbaugh, and Ivar

Bibliography

979

Jacobson, who jointly invented the UML, so we can assume that they know what they’re talking about.

The Unified Modeling Language User Guide (1998) is just what the title indicates. It explains the UML in detail, and is usually quite accessible, even for beginners. However, it does cover a great deal of advanced material.

The greater part of The Unified Modeling Language Reference Manual (1998) consists of an alphabetical listing of UML terms and constructs. Once you’ve learned something about the UML, it’s a handy reference.

UML Distilled, Second Edition (1999) by Martin Fowler and Kendall Scott is a quick tutorial of the UML. It is somewhat more accessible than the two books just mentioned, and much smaller. A good book for beginners.

Using UML by Perdita Stevens with Rob Pooley (2000) was designed as a textbook for university classes on the UML. However, it is small and easy to read.

Advanced Use Case Modeling (2001) by Frank Armour and Granville Miller tells you everything you might reasonably want to know about using use cases in software development processes.

UML in a Nutshell (1998) by Sinan Si Alhir is a useful reference. It’s not primarily a tutorial, so you will need to know something about the UML before you find it useful.

The History of C++

The Design and Evolution of C++ by Bjarne Stroustrup (Addison Wesley, 1994) is a description by its creator of how C++ came to be the way it is. It’s interesting in its own right, and knowing the history can even help you understand the language.

Ruminations on C++ by Andrew Koenig (Addison Wesley, 1997) is a rather informal discussion of various topics by one of the pioneers in C and C++. It’s easy to read and will give you fresh insights.

Other Topics

C++ IOStreams Handbook by Steve Teale (Addison Wesley, 1993) is a good explanation of the details of streams and files in C++. There’s material here you won’t find anywhere else.

The Standard Template Library by Alexander Stepanov and Meng Lee (Hewlett-Packard, 1994) is the defining document on the STL. You can learn all about the STL from it, but it doesn’t have many examples, and there are books that are easier to read. One is STL Tutorial and Reference Guide, Second Edition by David R. Musser, Gillmer J. Derge, and Atul Saini (Addison Wesley, 2001).

H

BIBLIOGRAPHY

Appendix H

980

Although it’s nominally based on Java, Object-Oriented Design in Java by Stephen Gilbert and Bill McCarty (Waite Group Press, 1998) is a comprehensive, easy-to-read introduction to OO program design in any language.

Windows Game Programming for Dummies by André LaMothe (IDG Books, 1998) is a fascinating look at the details of game programming. André’s book explains (among many other things) how to use the Windows console graphics routines, which form the basis of Console Graphics Lite routines discussed in Appendix E of this book. If you have any interest in writing game programs, buy this book.

The C Programming Language, Second Edition by Brian Kernighan and Dennis Ritchie (Prentice Hall PTR, 1988) is the definitive book about C, the language on which C++ was based. It’s not a primer, but once you know some C it’s the reference you’ll want.

INDEX

SYMBOLS

# (number sign), 35

&& (AND) logical operator, 115-116 ! (NOT) logical operator, 116-117

|| (OR) logical operator, 116-117 & (address-of) operator, 431-433 + (arithmetic) operator, 60

= (assignment) operator, 532-536, 539-546

— (decrement) operator, 65, 320 / (division) operator, 60

. (dot) operator, 360

== (equal to) operator, 77

>> (extraction) operator, 46-47

++ (increment) operator, 63-65, 320-322 << (insertion) operator, 34, 47, 54

* (multiplication) operator, 60 != (not equal to) operator, 77 % (remainder) operator, 61

[ ] (subscript) operator, 340-343 - (subtraction) operator, 60

A

abstract base classes, 392-393 abstract classes, 510

access specifiers default, 398

private access specifier, 377-379, 398-399 protected access specifier, 377, 379 public access specifier, 377-379, 399

tips for selecting, 399

access violation error message, 493 accessibility and inheritance, 376-377, 379

982

accessing

 

 

 

 

 

accessing

adjacent_find algorithm,

lower_bound algorithm,

 

 

array elements, 267

897

901

 

pointers, 441-442

Advanced Use Case

make_heap algorithm, 904

 

structures, 278

Modeling, 979

max algorithm, 905

 

base class members,

aggregates, 830-831

max_element algorithm,

 

376-377, 379

algorithms

905

 

characters in string objects,

accumulate algorithm,

merge algorithm, 733, 738,

 

309-310

733, 906

902

 

data with iterators,

adjacent_difference algo-

min algorithm, 905

 

759-760

rithm, 907

min_element algorithm,

 

elements of arrays, 267

adjacent_find algorithm,

905

 

pointers, 441-442

897

mismatch algorithm, 897

 

structures, 278

binary_search algorithm,

next_permutation algo-

 

member function data with

902

rithm, 906

 

this pointer, 547-548

containers, 755, 758-759

nth_element algorithm,

 

members of static func-

copy algorithm, 733, 897

901

 

tions, 531

copy_backward algorithm,

partial_sort algorithm, 901

 

members of structures,

898

partial_sort_copy algo-

 

136-137, 142-143

count algorithm, 732, 736,

rithm, 901

 

namespace members, 648

897

partial_sum algorithm,

 

accumulate algorithm,

count_if algorithm, 897

906-907

 

733, 906

equal algorithm, 732, 897

partition algorithm, 900

 

activity diagrams, 808,

equal_range algorithm,

pop_heap algorithm, 904

 

815-816

902

prev_permutation algo-

 

adapters

fill algorithm, 733, 898

rithm, 906

 

containers, 731-732

fill_n algorithm, 898

push_heap algorithm, 904

 

iterators

find algorithm, 732,

random_shuffle algorithm,

 

insert iterator, 763-766

735-736, 896

900

 

raw storage iterator,

find_if algorithm, 896

remove algorithm, 899

 

763

for_each algorithm, 733,

remove_copy algorithm,

 

reverse iterator,

742, 896

899

 

763-764

function objects, 739

remove_copy_if algorithm,

 

addition (+) operator, 60

generate algorithm, 899

899

 

address-of & operator,

generate_n algorithm, 899

remove_if algorithm, 899

 

431-433

if algorithm, 740-741

replace algorithm, 898

 

addresses in memory and

includes algorithm, 903

replace_copy algorithm,

 

pointers, 430-431

inner_product algorithm,

898

 

accessing variable pointed

906

replace_copy_if algorithm,

 

to, 436-439

inplace_merge algorithm,

898

 

address-of & operator,

902-903

replace_if algorithm, 898

 

431-433

iter_swap algorithm, 733,

reverse algorithm, 900

 

constants, 435-436

898

reverse_copy algorithm,

 

variables, 433-434

iterators, 757-758,

900

 

adjacent_difference

761-763, 909-911

rotate algorithm, 900

 

algorithm, 907

lexicographical_compare

rotate_copy algorithm, 900

 

 

algorithm, 905

search algorithm, 733,

 

 

 

737-738, 897

 

 

 

 

 

 

arrays

983

 

 

 

set_difference algorithm,

arguments

arrays, 728

 

903-904

exceptions, 714-717

arguments (functions),

 

set_intersection algorithm,

function templates,

446-448

 

903

686-689

bounds, 284-285

 

set_symmetric_difference

functions, 31, 66

buffers, 292

 

algorithm, 904

arrays, 274-276,

C-strings, 297-298

 

set_union algorithm, 903

446-448

class members, 279-283

 

sort algorithm, 733, 737,

C-strings, 453-454

data types, 264, 290

 

900

const function argu-

defining, 265-266, 271

 

sort_heap algorithm,

ments, 208-209, 254

elements

 

904-905

constants, 167-169

accessing, 267, 271,

 

stable_partition algorithm,

default arguments,

441-442

 

900

197-199

averaging, 267-268

 

stable_sort algorithm, 900

function templates, 686

overview, 265-267

 

STL, 726-727, 732-733,

naming, 176

sorting, 448-451

 

735-743, 896-907

objects, 233-234, 237

examples, 264-265,

 

swap algorithm, 733, 898

overloaded functions,

286-290

 

swap_ranges algorithm,

189-193

functions

 

898

parameters, 169

calling, 276

 

transform algorithm,

passing, 167-176

declarations, 275-276

 

742-743, 898

passing by pointers,

definitions, 276

 

unique algorithm, 899

444-448

passing, 275

 

unique_copy algorithm,

passing by reference,

index, 267

 

899

443-444

index numbers, 264

 

upper_bound algorithm,

references, 182-188

initializing, 268-270,

 

902

structures, 171-176

273-274

 

user-written functions,

values, 170-171

memory management,

 

739-740

variables, 169-170

458-459

 

uses, 726

manipulators, 572

multidimensional arrays

 

AND logical operator,

overloaded operators, 323

accessing elements, 271

 

115-116

arithmetic assignment

defining, 271

 

animation loops, 84

operator, 61-63, 337-339

formatting numbers,

 

The Annotated C++

arithmetic expressions,

272-273

 

Reference Manual, 978

479-484

initializing, 273-274

 

answer key to questions,

arithmetic operators

overview, 270-271

 

914-975

addition (+) operator, 60

objects, 283-284

 

append() member func-

arithmetic assignment

accessing, 285-286

 

tion, 307

operator, 61-63, 337-339

examples, 286-290

 

applications. See also pro-

division (/) operator, 60

in other computer lan-

 

grams

modulus operator, 61

guages, 264

 

console-mode applications

multiplication (*) operator,

passing to functions,

 

Borland C++Builder,

60

274-275

 

872-880

overloading, 328-334

pointers, 440-443

 

Microsoft Visual C++,

remainder (%) operator, 61

to objects, 467-468

 

864-870

subtraction (-) operator, 60

sorting array elements,

 

Landlord application, 809,

Armour, Frank, 979

448-451

 

811-843

 

to strings, 456-458

 

 

 

 

 

984

arrays

 

 

size, 265

attributes

arithmetic operators,

 

 

structures, 277-279

classes, 830

328-334

 

accessing elements, 278

definition, 15

comparison operators,

 

defining, 278

objects, 13

334-337

 

similarities, 264

auto keyword, 860

binary_search algorithm,

 

uses, 264

averaging, array ele-

902

 

ASCII character set, 43,

ments, 267-268

binding, 509

 

121

 

blanks in C-strings,

 

asm keyword, 860

 

293-294

 

assigning

B

blocks of code, 82

 

string objects, 303-304

Booch, Grady, 23, 804,

 

values to variables, 40-41

back() member function,

978

 

assignment expressions,

books about C++, 978-980

 

745-746

 

101-102

bool keyword, 860

 

bad alloc class, 717-718

 

Assignment operator

bool variables, 51-52, 114

 

badbit flag, 577

 

invoked message, 535

boolalpha flag, 571

 

base classes, 20, 372-376

 

assignment operators

Boole, George, 52

 

abstract base classes,

 

arithmetic assignment

Borland C++Builder

 

392-393

 

operator, 61-63

capabilities, 872

 

accessing members,

 

chaining, 535

Console Graphics Lite,

 

376-377, 379

 

inheritance, 536

878

 

destructors, 517-518

 

overloading, 539-546

debugging programs,

 

instantiating objects of,

 

overloading and self-

878-879

 

510

 

assignment, 552-556

breakpoints, 879-880

 

pure virtual functions,

 

prohibiting copying, 539

single-stepping, 879

 

510-511

 

assignment statements

tracing into functions,

 

virtual base classes,

 

overview, 40-41

879

 

518-520

 

structures, 139

watching variables, 879

 

begin() member function,

 

associations (classes),

executable programs,

 

731

 

357-358

875-876

 

behavior of objects, 13

 

associative containers,

file extensions, 872

 

bidirectional iterators,

 

727, 729, 771

header files, 876-877

 

733-734, 754-755

 

keys, 729-730, 771

projects, 873-878

 

binary I/O, 589-591

 

maps, 729-730, 771,

running example programs

 

binary operators, 117

 

775-778

in, 872

 

arithmetic assignment

 

multimaps, 730, 771,

screen elements, 873

 

operators, 337-339

 

775-778

Borland compilers, 30,

 

arithmetic operators,

 

multisets, 730, 771-775

885

 

328-334

 

sets, 729-730, 771-775

bounds of arrays, 284-285

 

comparison operators,

 

associativity of operators,

braces in functions, 31

 

334-337

 

447-448

break keyword, 109, 860

 

overloading, 328

 

at() member function, 309

break statement, 109,

 

arithmetic assignment

 

atoi() library function, 580

119-121

 

 

operators, 337-339

bsort() function, 450-451 bubble sorts, 450-451