1. Trang chủ
  2. » Công Nghệ Thông Tin

A Complete Guide to Programming in C++ part 83 pptx

10 207 0
Tài liệu đã được kiểm tra trùng lặp

Đang tải... (xem toàn văn)

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 10
Dung lượng 458,39 KB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

■ SCREEN CONTROL SEQUENCESThe following escape sequences reflect the ANSI standard for screen control.. Replace the # sign by the appropriate decimal number in all cases.. To enable thes

Trang 1

ASCII CODE TABLE (CONTINUED)

decimal octal hex character decimal octal hex character

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

95

96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127

60 61 62 63 64 65 66 67 68 69 6A 6B 6C 6D 6E 6F 70 71 72 73 74 75 76 77 78 79 7A 7B 7C 7D 7E 7F

`

a b c d e f g h i j k l m n o p q r s t u v w x y z {

| }

~ (DEL)

140 141 142 143 144 145 146 147 150 151 152 153 154 155 156 157 160 161 162 163 164 165 166 167 170 171 172 173 174 175 176 177

100

101

102

103

104

105

106

107

110

111

112

113

114

115

116

117

120

121

122

123

124

125

126

127

130

131

132

133

134

135

136

137

40 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 5B 5C 5D 5E 5F

@ A B C D E F G H I J K L M N O P Q R S T U V W X Y Z [

\ ]

^ _

A S C I I C O D E T A B L E 799

Trang 2

SCREEN CONTROL SEQUENCES

The following escape sequences reflect the ANSI standard for screen control Replace the # sign by the appropriate decimal number in all cases

ESC[#A Cursor # lines up

ESC[#B Cursor # lines down

ESC[#C Cursor # characters right

ESC[#D Cursor # characters left ESC[z,sH or ESC[z;sf Put cursor in line z and column s

ESC[s Save cursor position

ESC[u Load saved cursor position

ESC[#K # = 0: Delete from cursor position to line end

# = 1:Delete from start of line to cursor position

# = 2: Delete whole line

ESC[2J Clear screen ESC[#(;# )opm # = 0: all attributes normal

# = 1: switch double intensity on

# = 4: Underline on (monochrome screens)

# = 5: Blink on

# = 7: Inverse on

# = 3x: Foreground color

# = 4x: Background color

x = 0: black x = 4: blue

x = 1: red x = 5: magenta

x = 2: green x = 6: cyan

x = 3: yellow x = 7:white ESC[c1;c2p Change key assignments: The key with decimal code c1will

then return code c2

To enable these escape sequences, you must first load an appropriate screen device driver To do so for Windows 9x, place the following line in your CONFIG.SYS file DEVICE = C:\Windows\Command\Ansi.sys

Win NT and Win 2000 do not supply the ANSI screen control characters Correspond-ing functions based on system calls are offered for download

800 A P P E N D I X

Trang 3

LITERATURE

International Standard ISO/IEC 14882, Programming Languages—C++; published by

American National Standards Institute, New York NY, 1998

International Standard ISO/IEC 9899:1999(E), Programming Languages—C; published by

ISO Copyright Office, Case postale 56, CH-1211, Geneva 20, 1999

Stroustrup, Bjarne, The C++ Programming Language, Addison Wesley, 2000.

Josuttis, Nicolai, The C++ Standard Library, Addison Wesley, 1999.

L I T E R A T U R E 801

Trang 4

This page intentionally left blank

Trang 5

8 0 3

Note: Italicized page locators indicate figures

index

Symbols

&, 223, 231, 691

&&, 91

+, 50, 82, 85, 157

++, 85, 355

-, 82

, 85, 355, 420, 755

*, 82, 233, 255, 355, 691, 755

/, 82

%, 82

->, 255, 755

=, 87

+=, 50, 87

-=, 87, 355

*=, 87, 157

/=, 87

%=, 87

==, 88, 159

!=, 88, 159

<, 88, 159

<=, 88, 159

>, 88, 159

>=, 88, 159

<<, 9, 88, 229, 429

>>, 44, 229, 429 ::, 209

?:, 109 [], 691, 755 //, 91 /, 707 +-, 355

‘\n’, 51, 187 (), 691

A

Abstract classes, 565-585

concrete classes versus, 569

deriving, 569

and inhomogeneous lists, 574,

575-577

pointers and references to, 570 pure virtual methods for, 566 virtual assignment in, 572, 573

Trang 6

Abstraction, 245

Access methods, 274, 275

AccFileclass, 656

append()method of, 650, 651

Accountclass, 267, 392, 393

access methods for, 274

with constructors, 266

defining, 648

methods of, 248

read-only methods in, 276

sample class, 272

Account management index file, 655

accPtrarray

pointers in, 364

accSort()function, 682, 683

Accuracy, 21, 786

Adapter classes, 753

access to objects in, 761

constructors for, 757

deletion in, 765

insertion in, 759

Addition, 82, 353, 417

Addresses, array, 351

Address operator, 231, 412

Address space, hash file, 658

Algorithm library

within C++ standard library, 723

Alignment

and fill characters, 67

setting, 67

Ambiguity, 591

Ambiguous keys, 769

American National Standards Institute (ANSI),

3

Ampersand character, 223, 231, 691

Analysis, 245

ANDoperator, 91

Angled brackets

and header files, 47

template arguments stated in, 737

Appending

in arrays, 485

at end-of-file, 639

list elements, 465, 467

append()method, 333, 481, 485, 655

for class AccFile, 650

Applications

dynamic matrices, 694, 695 index files, 652, 653

inhomogeneous lists, 574-575 area()function

defining and calling, 176, 177

Argument pointer, 685 Arguments, 43 access to, 685

arrays as, 356 command line, 366, 367

functions without, 45 macros called with, 123 objects as, 235

objects passed as, 282 passing, 178

pointer arrays as, 683 pointers as, 235

template, 730, 731 variable number of, 684, 685, 686

argvarray

in memory, 366 Arithmetic operators, 20, 412 binary, 82 83

precedence of, 84 unary, 84, 85

Arithmetic shifts, 709 Arithmetic type conversions and precedence, 707

Arithmetic types, 20, 21

in assignments, 145 arrarray

in memory, 322

Array elements, 323 addressing, 353 arrays as, 331 index for, 323

pointers interrelated with, 352

Arrays appending/deleting in, 485

as arguments, 356

as array elements, 331 classFloatArr, 427

class representing, 426, 427 defining, 322, 323

dynamic, 461

804 I N D E X

Trang 7

dynamic storage allocation for, 460, 461

encapsulating, 333

initializing, 324, 325

length of, 357

member, 332

multidimensional, 330, 331

name and address of, 351

parameters declared as, 357

of pointers, 364

pointers moved in, 355

and pointer variables, 351

sample program, 350, 352

as sequential containers, 751

subscript operator for, 427

Arrow operator, 255

Articleclass, 287, 311

copy constructor of, 310

ASCII code (American Standard Code for

Informa-tion Interchange), 17, 800

Assignment operator, 87, 253, 412

overloading, 489

Assignments, 279, 488, 489

implicit type conversions in, 145, 531

type conversions in, 145, 532, 533

virtual, 572, 573 See also Compound assignments

Associative arrays, 427

Associative container classes, 769

Associative containers, 750, 751, 768, 769

and bitsets, 751

ATM (Asynchronous Transfer Mode) cells

header of, 714, 715

representing, 714

at()method, 165, 761

autokeyword, 205

Automatic lifetime, 199

auto objects, 205

autospecifier, 204

B

back()method

and container classes vector, deque, and list, 761

Backslashes, 29

bad_cast, 553

badbit, 645

Base classes, 383, 501

accessibility of, 589

access to members in, 503, 509 calling methods in, 513 conversions in references to, 535

converting to, 530, 531 multiple indirect, 590, 591 virtual, 592, 593

with virtual destructors, 548, 549

Base class object assignment, 533 Base class pointer conversion, 535 BaseE1class, 575

defining, 574

Base initializers, 511, 595, 597, 655 Base subobject, 505

begin()method, 755, 769 Bell Laboratories, 3 Bias, 786

Bidirectional iterators, 755

Binary arithmetic operators, 82, 83

Binary bitwise operators, 713 Binary complement, 143 Binary mode

file opened in, 638 Binary operator, 415, 417

and operands, 82

Binary search algorithm, 643 Binary trees, 187

Binding, 551 Bit coded data, 707

Bit-fields, 714

defining, 715 Bitmapcontainer class, 774, 775

Bitmaps

raster images represented with, 774, 775 Bit masks, 710, 711

creating, 713

using, 712

Bit patterns retaining, 143 Bits

deleting, 711 manipulating, 777

Bitsets, 774, 775, 776, 777

associative containers and, 751 declaring, 775

BitwiseANDoperator, 711 Bitwise exclusive ORoperator, 711

I N D E X 805

Trang 8

Bitwise operators, 412, 706, 707, 751

for bit manipulation, 777

in compound assignments, 713

for creating bit masks, 713

BitwiseORoperator, 711

Bitwise shift operators, 707, 708, 709

Blocks, building, 97

Block scope

object defined with, 199

Boolean constants, 23

Boolean operator precedence, 91

Boolean values, 17

output of, 68, 69, 71

types for, 16

booltype, 17, 23, 91

Braces

and functions without arguments, 45

and variables, 33

Brackets

and parameters for macros, 123

in syntax descriptions, 612

Branches, 125

breakstatement, 113

sample program containing, 112

Bresenham algorithm, 776, 777

Bubble sort algorithm, 334

Built-in types, 17

C

C

programming language, 3, 49, 51

standard library header files, 48

C++

characteristics of, 2, 3

conventions in, 31

developing/translating programs in, 6, 7

historical perspective on, 3

keywords in, 30

programming language, 3

sample program, 8, 18

standard library, 7, 9, 48, 173, 723, 751, 753, 773

calc()function, 618, 619

Calling environment, 611

Capacities, 5, 763

capital()function

defining, 182

Carclass, 504 accessing members of, 506 virtual method table for, 550

Case conversion and macros, 129 Case labels, 111 Casting, 147 Castleclass, 514, 515

Cast operator, 147 catchblock, 615

nested, 616, 617 syntax of, 612, 613 Catching exceptions, 614

cctypeheader file, 129 Cell base class

and derived classes, 574

cerrstream, 58, 59 cfloatheader file, 21 Character by character string comparison, 159 Character codes, 17, 69

Character constants, 23, 25

examples for, 24

Character manipulation

standard macros for, 128

Characters, 17

output of, 68, 69

reading and writing, 75 testing, 129

types for, 16

Character set, 17 chararrays, 327 CHAR_MAX, 19 CHAR_MIN, 19 charpointers, 351 array of, 367

sample function, 364

chartype, 17, 19, 25, 112 charvectors, 327 cin, 429

cinstream, 47, 49, 58, 61 Class arrays

declaring, 329

sample program, 328

Class(es), 5, 245 abstract, 565-585 adapter, 753

806 I N D E X

Trang 9

associative container, 769

base, 501

container, 753

defining, 246, 247

derived, 501

dynamic members of, 479, 480

dynamic storage allocation for, 458

example of, 246

exception, 611

friend, 424, 425

and friend functions, 423

and global functions, 51

I/O stream, 59

iterator, 755

multiply-derived, 588, 589

naming, 247

operators for, 413 See also Abstract classes;

Adapter classes; Base classes; Derived classes;

Type conversion for classes

classkeyword, 247, 257

Class member access operator, 253

Class-specific constants, 309

Class template, 723

defining, 725

for sequences, 753

clear()method, 70, 645

for deleting objects in container classes, 765

for erasing containers, 771

and maps/multimaps, 773

Client class, 303

climitsheader file, 19

clogstream, 58, 59

close()method, 389

Closing files, 388, 389

CLS macro, 123

cmathheader file, 41

Collision resolution, 658

Collisions, 658

Colons

after labels, 113

Command line arguments, 367

sample program, 366

Comma operator, 412

syntax for, 101

Commas

for separating member initializers, 301

Comments

C++ program with, 10

examples of, 11 Comparative operators, 88, 159, 355 Comparator class, 753

compare()function, 689 Comparisons

results of, 89, 159, 355 Compiler, 7

Complex declarations, 690

operators and, 691 rules for evaluating, 691 complexheader file, 48 Compound assignments, 145 bitwise operators in, 713

demonstration of, 86

operators, 87 Compound conditions, 91 Concatenation operators, 50, 157 Concrete classes

abstract classes versus, 569

Conditional expressions, 109 compilation, 790

structogram for, 108 Conditional inclusion, 126, 127

Conditional operator precedence, 109 conio.hheader file, 132

Constants, 23, 25 class-specific, 309 const_iteratortype, 755 constkeyword, 34, 36, 64, 223 constmember object declaration, 303 Constobjects/methods

accessing, 276, 277

pointers to, 361

Constructor calls, 594, 595

and initialization, 595

sample program, 268

in virtual base classes, 597 Constructors, 251, 465 Accountclass with, 266

for adapter classes, 757 calling, 269, 299

conversion, 442, 443

copy, 279 declaring, 267

I N D E X 807

Trang 10

Constructors (continued)

default, 269, 279

defining, 266, 267

initializing, 269

with inline definitions, 273

task of, 267

of vector, list, and deque, 757 See also Destructors

Container adapters, 752

Container classes, 753, 768

deleting objects in, 765

Containers, 749-782

description of, 751

length and capacity of, 763

positioning and iterating in, 755

types of, 750, 751

Containers Library, 751, 753

Contiguous memory space, 323

continuestatement, 113

Control, 28

Controlling expression, 97

ControlPointclass, 424, 425

Conversion constructors, 442, 443

Conversion functions, 443

conversion constructor versus, 445

defining, 445

“Cooked mode,” 386

Copy constructor, 279

effect of standard, 486

forFloatArrclass, 486, 487

proprietary version of, 487

cos()function, 40

Counter

initializing, 99

count()method

and maps/multimaps, 773

count variable, 643

cout, 9, 30, 32

coutstream, 47, 49, 58, 61

Coworker class, 566, 567

assignment for, 572, 573

CPU registers, 205

cstdlibheader file, 45

C strings

initializing, 326

specializing function template for, 732

and string class, 327

ctime()function, 167 ctype.hheader file, 48 Current file position, 381 currentTime()global function, 284, 285

D

Data abstraction, 3, 245, 501 bit coding, 707

class-specific, 305 encapsulation, 3, 245, 273 structures, 463

Data blocks transferring, 391 Data handling with traditional procedural programming, 5 Data members, 51, 245

and methods, 505

static, 304, 305

Dateclass methods, 288

Daytimeclass operators, 414

DayTimesample class, 280

Debuggers, 7 DEC Alpha workstations and bit-fields, 715 Decimal constant, 23 Decimals

floating-point numbers represented as, 25 Declarations, 41

within header files, 47

Declaring sequences, 756, 757

decmanipulator, 63, 73 Decrement operator, 85 and bidirectional iterators, 755

Default arguments, 182, 183 defining, 182, 183

rules for and setting of, 735

of templates, 734, 735

defaultconstructors, 269, 279, 299, 461 Default destructors, 271

defaultlabel, 111 Default settings, for flags, 61

#definedirective, 121, 127 enumconstants contrasted with, 309

working with, 124, 125

deleteoperator, 455, 456, 457, 459

808 I N D E X

Ngày đăng: 06/07/2014, 17:21