Index

!. See Not, 1087

!=. See Not equal (inequality), 67, 1088, 1101

"...". See String literal, 62

#. See Preprocessor directives, 1129

$. See End of line, 873, 1178

%. See Output format specifier, 1187

Remainder (modulo), 68

%=. See Remainder and assign, 1090

&. See Address of, 588, 1087

Bitwise logical operations (and), 956, 1089, 1094

Reference to (in declarations), 276279, 1099

&&. See Logical and, 1089, 1094

&=. See Bitwise logical operations (and and assign), 1090

.'. .'. See Character literals, 161, 10791080

(). See Expression (grouping), 95, 867, 873, 876

Function call, 285, 766

Function of (in declarations), 113115, 1099

Regular expression (grouping), 1178

*. See Contents of (dereference), 594

Multiply, 1088

Pointer to (in declarations), 587, 1099

Repetition (in regex), 868, 873874, 1178

*/ end of block comment, 238

*=. See Multiply and assign (scale), 67

+. See Add, 66, 1088

Concatenation (of strings), 6869, 851, 1176

Repetition in regex, 873875, 1178

++. See Increment, 66, 721

+=. See Add and assign, 1089

Move forward, 1101

string (add at end), 851, 1176

, (comma). See Comma operator, 1090

List separator, 1103, 11221123

. See Minus (substraction), 66, 1088

Regular expression (range), 877

––. See Decrement, 66, 1087, 1141

–> (arrow). See Member access, 608, 1087, 1109, 1141

= See Move backward, 1101, 1142

Subtract and assign, 67, 1090

. (dot). See Member access, 306, 607608, 10861087

Regular expression, 872, 1178

... (ellipsis). See Arguments (unchecked), 11051106

Catch all exceptions, 152

/. See Divide, 66, 1088

//. See Line comment, 45

/*. . .*/. See Block comment, 238

/=. See Divide and assign, 67, 1090

: (colon). See Base and member initializers, 315, 477, 555

Conditional expression, 268

Label, 106108, 306, 511, 1096

::. See Scope (resolution), 295, 314, 1083, 1086

; (semicolon). See Statement (terminator), 50, 100

<. See Less than, 67, 1088

<<. See Bitwise logical operations (left shift), 956, 1088

Output, 363365, 1173

<=. See Less than or equal, 67, 1088

<<=. See Bitwise logical operations (shift left and assign), 1090

<. . .>. See Template (arguments and parameters), 153, 678679

=. See Assignment, 66, 1090

Initialization, 6973, 1219

==. See Equal, 67, 1088

>. See Greater than, 67, 1088

Input prompt, 223

Template (argument-list terminator), 679

>=. See Greater than or equal, 67, 1088

>>. See Bitwise logical operations (right shift), 956, 1088

Input, 61, 365

>>=. See Bitwise logical operations (shift right and assign), 1090

?. See Conditional expression, 268, 1089

Regular expression, 867868, 873, 874875, 1178

[]. See Array of (in declaration), 649, 1099

Regular expression (character class), 872, 1178

Subscripting, 594, 649, 1101

(backslash). See Character literal, 10791080

Escape character, 1178

Regular expression (escape character), 866867, 873, 877

^. See Bitwise logical operations (exclusive or), 956, 1089, 1094

Regular expression (not), 873, 1178

^=. See Bitwise logical operations (xor and assign), 1090

_. See Underscore, 75, 76, 1081

{}. See Block delimiter, 47, 111

Initialization, 83

List, 83

Regular expression (range), 867, 873875, 1178

|. See Bitwise logical operations (bitwise or), 956, 1089, 1094

Regular expression (or), 867868, 873, 876, 1178

|=. See Bitwise logical operations (or and assign), 1090

||. See Logical or, 1089, 1094

~. See Bitwise logical operations (complement), 956, 1087

Destructors, 601603

0 (zero). See Null pointer, 598

Prefix, 382, 384

printf() format specifier, 11881189

0x. See Prefix, 382, 384

A

a, append file mode, 1186

a alert, character literal, 1079

abort(), 11941195

abs(), absolute value, 917, 1181

complex, 920, 1183

Abstract classes, 495, 1217

class hierarchies, 512

creating, 495, 512, 11181119

Shape example, 495496

Abstract-first approach to programming, 10

Abstraction, 9293, 1217

level, ideals, 812813

Access control, 306, 505, 511

base classes, 511

encapsulation, 505

members, 492493

private, 505, 511

private by default, 306307

private: label, 306

private vs. public, 306308

protected, 505, 511

protected: label, 511

public, 306, 505, 511

public by default, 307308. See also struct

public: label, 306

Shape example, 496499

accumulate(), 759, 770772, 1183

accumulator, 770

generalizing, 772774

acos(), arccosine, 917, 1182

Action, 47

Activation record, 287. See also Stacks

Ada language, 832833

Adaptors

bind(), 1164

container, 1144

function objects, 1164

mem_fn(), 1164

not1(), 1164

not2(), 1164

priority_queue, 1144

queue, 1144

stack, 1144

add(), 449450, 491492, 615617

Add (plus) +, 66, 1088

Add and assign +=, 66, 73, 1090

Additive operators, 1088

Address, 588, 1217

unchecked conversions, 943944

Address of (unary) &, 588, 1087

Ad hoc polymorphism, 682683

adjacent_difference(), 770, 1184

adjacent_find(), 1153

advance(), 615617, 739, 1142

Affordability, software, 34

Age distribution example, 538539

Alert markers, 3

Algol60 language, 827829

Algol family of languages, 826829

<algorithm>, 759, 1133

Algorithms, 1217

and containers, 722

header files, 11331134

numerical, 11831184

passing arguments to. See Function objects

Algorithms, numerical, 770, 11831184

accumulate(), 759, 770774, 1183

adjacent_difference(), 770, 1184

inner_product(), 759, 770, 774776, 1184

partial_sum(), 770, 1184

Algorithms, STL, 11521153

<algorithm>, 759

binary_search(), 796

comparing elements, 759

copy(), 758, 789790

copy_if(), 789

copying elements, 758

count(), 758

count_if(), 758

equal(), 759

equal_range(), 758, 796

find(), 758, 759763

find_if(), 758, 763764

heap, 1160

lower_bound(), 796

max(), 1161

merge(), 758

merging sorted sequences, 758

min(), 1161

modifying sequence, 11541156

mutating sequence, 11541156

nonmodifying sequence, 11531154

numerical. See Algorithms, numerical

permutations, 11601161

search(), 795796

searching, 11571159. See also find_if(); find()

set, 11591160

shuffle(), 11551156

sort(), 758, 794796

sorting, 758, 794796, 11571159

summing elements, 759

testing, 10011008

unique_copy(), 758, 789, 792793

upper_bound(), 796

utility, 1157

value comparisons, 11611162

Aliases, 1128, 1217. See also References

Allocating memory. See also Deallocating memory; Memory

allocator_type, 1147

bad_alloc exception, 1094

C++ and C, 10431044

calloc(), 1193

embedded systems, 935936, 940942

free store, 593594

malloc(), 10431044, 1193

new, 10941095

pools, 940941

realloc(), 1045

stacks, 942943

allocator_type, 1147

Almost containers, 751, 1145

alnum, regex character class, 878, 1179

alpha, regex character class, 878, 1179

Alternation

patterns, 194

regular expressions, 876

Ambiguous function call, 1104

Analysis, 35, 176, 179

and, synonym for &, 1037, 1038

and_eq, synonym for &=, 1037, 1038

app mode, 389, 1170

append(), 851, 1177

Append

files, 389, 1186

string +=, 851

Application

collection of programs, 1218

operator (), 766

Approximation, 532537, 1218

Arccosine, acos(), 917

Arcsine, asin(), 918

Arctangent, atan(), 918

arg(), of complex number, theta, 920, 1183

Argument deduction, 689690

Argument errors

callee responsibility, 143145

caller responsibility, 142143

reasons for, 144145

Arguments, 272, 1218

formal. See Parameters

functions, 11051106

passing. See Passing arguments

program input, 91

source of exceptions, 147148

templates, 11221123

types, class interfaces, 324326

unchecked, 10291030, 11051106

unexpected, 136

Arithmetic if ?:, 268. See also Conditional expression ?:

Arithmetic operations. See Numerics

<array>, 1133

Arrays, 648650, 1218. See also Containers; vector

[] declaration, 649

[] dereferencing, 649

accessing elements, 649, 899901

assignment, 653654

associative. See Associative containers

built-in, 747749

copying, 653654

C-style strings, 654655

dereferencing, 649

element numbering, 649

initializing, 596598, 654656

multidimensional, 895897, 1102

palindrome example, 660661

passing pointers to arrays, 944951

pointers to elements, 650652

range checking, 649

subscripting [], 649

terminating zero, 654655

vector alternative, 947951

Arrays and pointers, 651658

debugging, 656659

array standard library class, 747749, 1144

asin(), arcsine, 918, 1182

asm(), assembler insert, 1037

Assemblers, 820

Assertions

assert(), 1061

<cassert>, 1135

debugging, 163

definition, 1218

assign(), 1148

Assignment =, 6973

arrays, 653654

assignment and initialization, 6973

composite assignment operators, 7374

containers, 1148

Date example, 309310

enumerators, 318319

expressions, 10891090

string, 851

vector, resizing, 675677

Assignment operators (composite), 66

%=, 73, 1090

&=, 1090

*=, 73, 1089

+=, 73, 1090, 1141

=, 73, 1090, 1142

/=, 73, 1090

<<=, 1090

>>=, 1090

^=, 1090

|=, 1090

Associative arrays. See Associative containers

Associative containers, 776, 1144

email example, 856860

header files, 776

map, 776

multimap, 776, 860861

multiset, 776

operations, 11511152

set, 776

unordered_map, 776

unordered_multimap, 776

unordered_multiset, 776

unordered_set, 776

Assumptions, testing, 10091011

at(), range-checked subscripting, 693694, 1149

atan(), arctangent, 918, 1182

ate mode, 389, 1170

atof(), string to double, 1192

atoi(), string to int, 1192

atol(), string to long, 1192

AT&T Bell Labs, 838

AT&T Labs, 838

attach() vs. add() example, 491492

auto, 732734, 760

Automatic storage, 591592, 1083. See also Stack storage

Axis example, 424426, 443, 529532, 543546

B

b, binary file mode, 1186

Babbage, Charles, 832

back(), last element, 737, 1149

back_inserter(), 1162

Backus, John, 823

Backus-Naur (BNF) Form, 823, 828

bad_alloc exception, 1094

bad() stream state, 355, 1171

Base-2 number system (binary), 10781079

Base-8 number system (octal), 10771078

Base-10

logarithms, 918

number system (decimal), 10771078

Base-16 number system (hexadecimal), 10771078

Balanced trees, 780782

Base and member initializers, 315, 477, 555

Base classes, 493496, 504507, 1218

abstract classes, 495, 512513, 11181119

access control, 511

derived classes, 11161117

description, 504506

initialization of, 477, 555, 1113, 1117

interface, 513514

object layout, 506507

overriding, 508511

Shape example, 495496

virtual function calls, 501, 506507

vptr, 506

vtbl, 506

Base-e exponentials, 918

basic_string, 852

Basic guarantee, 702

BCPL language, 838

begin()

iterator, 1148

string, 851, 1177

vector, 721

Bell Telephone Laboratories (Bell Labs), 836, 838842, 10221023

Bentley, John, 933, 966

Bidirectional iterator, 1142

bidirectional iterators, 752

Big-O notation, complexity, 785

Binary I/O, 390393

binary mode, 389, 1170

Binary number system, 10781079

Binary search, 758, 779, 795796

binary_search(), 796, 1158

bind() adaptor, 1164

bitand, synonym for &, 1037, 1038

Bitfields, 956957, 967969, 11201121

bitor, synonym for |, 1038

Bits, 78, 954, 1218

bitfields, 956957

bool, 955

char, 955

enumerations, 956

integer types, 955

manipulating, 965967

signed, 961965

size, 955956

unsigned, 961965

<bitset>, 1133

bitset, 959961

bitwise logical operations, 960

construction, 959

exceptions, 1138

I/O, 960

Bitwise logical operations, 956959, 1094

and &, 956957, 1089, 1094

or |, 956, 1089, 1094

or and assign, |=, 966

and and assign &=, 1090

complement ~, 956

exclusive or ^, 956, 1089, 1094

exclusive or and assign ^=, 1089

left shift <<, 956

left shift and assign <<=, 1089

right shift >>, 956

right shift and assign >>=, 1089

Blackboard, 36

Black-box testing, 992993

blank, character class, regex, 878, 1179

Block, 111

debugging, 161

delimiter, 47, 111

nesting within functions, 271

try block, 146147

Block comment /*. . .*/, 238

Blue marginal alerts, 3

BNF (Backus-Naur) Form, 823, 828

Body, functions, 114

bool, 63, 6667, 1099

bits in memory, 78

bit space, 955

C++ and C, 1026, 1038

size, 78

boolalpha, manipulator, 1173

Boolean conversions, 1092

Borland, 831

Bottom-up approach, 9, 811

Bounds error, 149

Branching, testing, 10061008. See also Conditional statements

break, case label termination, 106108

Broadcast functions, 903

bsearch(), 11941195

Buffer, 348

flushing, 240241

iostream, 406

overflow, 661, 792, 1006. See also gets(), scanf()

Bugs, 158, 1218. See also Debugging; Testing

finding the last, 166167

first documented, 824825

regression tests, 993

Built-in types, 304, 1099

arrays, 747749, 11011102

bool, 77, 1100

characters, 77, 891, 1100

default constructors, 328

exceptions, 1126

floating-point, 77, 891895, 1100

integers, 77, 891895, 961965, 1100

pointers, 588590, 11001101

references, 279280, 11021103

Button example, 443, 561563

attaching to menus, 571

detecting a click, 557

Byte, 78, 1218

operations, C-style strings, 10481049

C

.c suffix, 1029

.cpp, suffix, 48, 1200

C# language, 831

C++ language, 839842. See also Programming; Programs; Software

coding standards, list of, 983

portability, 11

use for teaching, xxiv, 69

C++ and C, 10221024

C functions, 10281032

C linkage convention, 1033

C missing features, 10251027

calling one from the other, 10321034

casts, 10401041

compatibility, 10241025

const, 10541055

constants, 10541055

container example, 10591065

definitions, 10381040

enum, 1042

family tree, 1023

free-store, 10431045

input/output, 10501054

keywords, 10371038

layout rules, 1034

macros, 10541059

malloc(), 10431044

namespaces, 10421043

nesting structs, 1037

old-style casts, 1040

opaque types, 1060

performance, 1024

realloc(), 1045

structure tags, 10361037

type checking, 10321033

void, 1030

void*, 10411042

“C first” approach to programming, 9

C language, 836839. See also C standard library

C++ compatibility, 10221024. See also C++ and C

K&R, 838, 10221023

linkage convention, 1033

missing features, 10251027

C standard library

C-style strings, 1191

header files, 1135

input/output. See C-style I/O (stdio)

memory, 11921193

C-style casts, 10401041, 1087, 1095

C-style I/O (stdio)

%, conversion specification, 1187

conversion specifications, 11881189

file modes, 1186

files, opening and closing, 1186

fprintf(), 10511052, 1187

getc(), 1052, 1191

getchar(), 1045, 10521053, 1191

gets(), 1052, 11901191

output formats, user-defined types, 11891190

padding, 1188

printf(), 10501051, 1187

scanf(), 10521053, 1190

stderr, 1189

stdin, 1189

stdout, 1189

truncation, 1189

C-style strings, 654655, 10451047, 1191

byte operations, 10481049

const, 10471048

copying, 10461047, 1049

executing as a command, system(), 1194

lexicographical comparison, 1046

operations, 11911192

pointer declaration, 10491050

strcat(), concatenate, 1047

strchr(), find character, 1048

strcmp(), compare, 1046

strcpy(), copy, 1047, 1049

from string, c_str(), 350, 851

strlen(), length of, 1046

strncat(), 1047

strncmp(), 1047

strncpy(), 1047

three-way comparison, 1046

CAD/CAM, 27, 34

Calculator example, 174, 186188

analysis and design, 176179

expression(), 197200

get_token(), 196

grammars and programming, 188195

parsing, 190193

primary(), 196, 208

symbol table, 247

term(), 196, 197202, 206207

Token, 185186

Token_stream, 206214, 240241

Call stack, 290

Callback functions, 556559

Callback implementation, 12081209

Calling functions. See Function calls

calloc(), 1193

Cambridge University, 839

capacity(), 673674, 1151

Capital letters. See Case (of characters)

Case (of characters)

formatting, 397398

identifying, 397

islower(), 397, 1175

map container, 782

in names, 7477

sensitivity, 397398

tolower(), changing case, 398, 1176

toupper(), changing case, 398, 1176

case labels, 106108

<cassert>, 1135

Casting away const, 609610

Casts. See also Type conversion

C++ and C, 1026, 1038

casting away const, 609

const_cast, 1095

C-style casts, 10401041

dynamic_cast, 932, 1095

lexical_cast example, 855

narrow_cast example, 153

reinterpret_cast, 609

static_cast, 609, 944, 1095

unrelated types, 609

CAT scans, 30

catch, 147, 1038

Catch all exceptions ., 152

Catching exceptions, 146153, 239241, 1126

cb_next() example, 556559

<cctype>, 1135, 1175

ceil(), 917, 1181

cerr, 151, 1169, 1189

<cerrno>, 1135

<cfloat>, 1135

Chaining operations, 180181

Character classes

list of, 1179

in regular expressions, 873874, 878

Character classification, 397398, 11751176

Character literals, 161, 10791080

CHAR_BIT limit macro, 1181

CHAR_MAX limit macro, 1181

CHAR_MIN limit macro, 1181

char type, 63, 6667, 78

bits, 955

built-in, 1099

properties, 741742

signed vs. unsigned, 894, 964

cin, 61

C equivalent. See stdin

standard character input, 61, 347, 1169

Circle example, 469472, 497

vs. Ellipse, 474

Circular reference. See Reference (circular)

class, 183, 10361037

Class

abstract, 495, 512513, 11181119. See also Abstract classes

base, 504506

coding standards, 981

concrete, 495496, 1218

const member functions, 1110

constructors, 11121114, 11191120

copying, 1115, 1119

creating objects. See Concrete classes

default constructors, 327330

defining, 212, 305, 1108, 1218

derived, 504

destructors, 11141115, 1119

encapsulation, 505

friend declaration, 1111

generated operations, 11191120

grouping related, 512

hierarchies, 512

history of, 834

implementation, 306308

inheritance, 504505, 513514

interface, 513514

member access. See Access control

naming. See Namespaces

nesting, 270

object layout, 506507

organizing. See Namespaces

parameterized, 682683. See also Template

private, 306308, 505, 511, 11081109

protected, 495, 505, 511

public, 306308, 505, 511, 11081109

run-time polymorphism, 504505

subclasses, 504. See also Derived classes

superclasses, 504. See also Base classes

templates, 681683

this pointer, 1110

types as parameters. See Template

union, 1121

unqualified name, 1110

uses for, 305

Class interfaces, 323, 1108

argument types, 324326

const member functions, 330332

constants, 330332. See also const

copying, 326327

helper functions, 332334

immutable values, 330332

initializing objects, 327330

members, 332334

mutable values, 332334

public vs. private, 306308

symbolic constants, defining, 326

uninitialized variables, 327330

Class members, 305, 1108

. (dot), 306, 1109

:: (scope resolution), 1109

accessing, 306. See also Access control

allocated at same address, 1121

bitfields, 11201121

in-class definition, 1112

class interfaces, 332334

data, 305

definitions, 1112

function, 314316

out-of-class definition, 1112

Token_stream example, 212

Token example, 183184

Class scope, 267, 1083

Class template

parameterized class, 682683

parameterized type, 682683

specialization, 681

type generators, 681

classic_elimination() example, 910911

Cleaning up code

comments, 237238

functions, 234235

layout, 235236

logical separations, 234235

revision history, 237238

scaffolding, 234235

symbolic constants, 232234

clear(), 355358, 1150

<climits>, 1135

<clocale>, 1135

clock(), 10151016, 1193

clock_t, 1193

clone() example, 504

Closed_polyline example, 456458

vs. Polygon, 458

close() file, 352

<cmath>, 918, 1135, 1182

cntrl, 878, 1179

COBOL language, 823825

Code

definition, 1218

layout, cleaning up, 235236

libraries, uses for, 177

storage, 591592

structure, ideals, 810811

test coverage, 1008

Coding standards, 974975

C++, list of, 983

complexity, sources of, 975

ideals, 976977

sample rules, 977983

Color example, 425426, 450452

color chat example, 465467

fill, 431432, 462464, 500

transparency, 451

Columns, matrices, 900901, 906

Command-line, 47

Comments, 4546

block /*. . .*/, 238, 1076

C++ and C, 1026

cleaning up, 237238

vs. code, 238

line //, 4546, 1076

role in debugging, 159160

Common Lisp language, 825

Communication skills, programmers, 22

Compacting garbage collection, 938939

Comparison, 67. See also <; ==

C-style strings, 10451047

characters, 740

containers, 1151

key_compare, 1147

lexicographical, C-style strings, 1046

lexicographical_compare(), 1162

min/max algorithms, 11611162

string, 851

three-way, 1046

Compatibility. See C++ and C

Compile-time errors. See Errors, compile-time

Compiled languages, 4748

Compilers, 48, 1218

compile-time errors, 51

conditional compilation, 10581059

syntax checking, 4850

compl, synonym for ~, 1037, 1082

complex

*, multiply, 919, 1183

+, add (plus), 919, 1183

<<, output, 1183

!=, not equal (inequality), 919, 1183

==, equal, 919, 1183

>>, input, 920, 1183

/, divide, 919, 1183

<<, output, 920

abs(), absolute value, 920, 1183

conj(), conjugate, 920

Fortran language, 920

imag(), imaginary part, 920

norm(), square of abs(), 919

number types, 11821183

polar(), polar coordinate, 920

real(), real part, 920

rho, 920

square of abs(), 919

theta, 920

<complex>, 1134

complex operators, 919920, 1183

standard math functions, 1181

Complex numbers, 919920

Complexity, 1218

sources of, 975

Composite assignment operators, 7374

Compound statements, 111

Computation, 91. See also Programs; Software

correctness, 9294

data structures, 9091

efficiency, 9294

input/output, 91

objectives, 9294

organizing programs, 9294

programmer ideals, 9294

simplicity, 9294

state, definition, 9091

Computation vs. data, 717720

Computer-assisted surgery, 30

Computers

CAT scans, 30

computer-assisted surgery, 30

in daily life, 1921

information processing, 32

Mars Rover, 33

medicine, 30

pervasiveness of, 1921

server farms, 3132

shipping, 2628

space exploration, 33

telecommunications, 2829

timekeeping, 26

world total, 19

Computer science, 12, 2425

Concatenation of strings, 66

+, 6869, 851, 1176

+=, 6869, 851, 1176

Concept-based approach to programming, 6

Concrete classes, 495496, 1218

Concrete-first approach to programming, 6

Concurrency, 932

Conditional compilation, 10581059

Conditional expression ?:, 268, 1089

Conditional statements. See also Branching, testing

for, 111113

if, 102104

switch, 105109

while, 109111

Conforming programs, 1075

Confusing variable names, 77

conj(), complex conjugate, 920, 1183

Conjugate, 920

Consistency, ideals, 814815

Console, as user interface, 552

Console input/output, 552

Console window, displaying, 162

const, 9597. See also Constant; Static storage, static const

C++ and C, 1026, 10541055

class interfaces, 330332

C-style strings, 10471048

declarations, 262263

initializing, 262

member functions, 330332, 1110

overloading on, 647648

passing arguments by, 276278, 281284

type, 1099

*const, immutable pointer, 1099

Constant. See also const, expressions, 1093

const_cast, casting away const, 609, 1095

const_iterator, 1147

constexpr, 96-97, 290-291, 1093, 1104

Constraints, vector range checking, 695

Constructors, 310312, 11121114. See also Destructors; Initialization

containers, 1148

copy, 633634, 640646

Date example, 311

Date example 307, 324326

debugging, 643646

default, 327330, 1119

error handling, 313, 700702

essential operations, 640646

exceptions, 700702

explicit, 642643

implicit conversions, 642643

initialization of bases and members, 315, 477, 555

invariant, 313314, 701702

move, 637640

need for default, 641

Token example, 184

Container adaptors, 1144

Containers, 148, 749751, 1218. See also Arrays; list; map, associative array; vector

and algorithms, 722

almost containers, 751, 1145

assignments, 1148

associative, 1144, 11511152

capacity(), 11501151

of characters. See string

comparing, 1151

constructors, 1148

contiguous storage, 741

copying, 1151

destructors, 1148

element access, 1149

embedded systems, 951954

header files, 11331134

information sources about, 750

iterator categories, 752

iterators, 1148

list operations, 1150

member types, 1147

operations overview, 11461147

queue operations, 1149

sequence, 1144

size(), 1150

stack operations, 1149

standard library, 11441152

swapping, 1151

templates, 686687

Contents of * (dereference, indirection), 594

Contiguous storage, 741

Control characters, iscntrl(), 397

Control inversion, GUIs, 569570

Control variables, 110

Controls. See Widget example

Conversion specifications, printf(), 11881189

Conversion. See also Type conversion

character case, 398

representation, 374376

unchecked, 943944

Coordinates. See also Point example

computer screens, 419420

graphs, 426427

copy(), 789790, 1154

Copy assignments, 634636, 640646

Copy constructors, 633634, 640646

copy_backward(), 1154

copy_if(), 789

Copying, 631637

arrays, 653654

class interfaces, 326327

containers, 1151

C-style strings, 10461047, 1049

I/O streams, 790793

objects, 503504

sequences, 758, 789794

vector, 631636, 1148

Correctness

definition, 1218

ideals, 9294, 810

importance of, 929930

software, 34

cos(), cosine, 527528, 917, 1181

cosh(), hyperbolic cosine, 1182

Cost, definition, 1219

count(), 758, 1154

count_if(), 758, 1154

cout, 45

C equivalent. See stdout

printing error messages, 151. See also cerr

standard output, 347, 1169

Critical systems, coding standards, 982983

<cstddef>, 1136

<cstdio>, 1135

<cstdlib>, 1135, 1193, 1194

c_str(), 1177

<cstring>, 1135, 1175, 1193

<ctime>, 1135, 1193

Ctrl D, 124

Ctrl Z, 124

Current object, 317. See also this pointer

Cursor, definition, 45

<cwchar>, 1136

<cwctype>, 1136

D

d, any decimal digit, regex, 878, 1179

d, decimal digit, regex, 873, 1179

D, not a decimal digit, regex, 873, 1179

d suffix, 1079

Dahl, Ole-Johan, 833835

Data. See also Containers; Sequences; list; map, associative array; vector

abstraction, 816

collections. See Containers

vs. computation, 717720

generalizing code, 714716

in memory. See Free store (heap sotrage)

processing, overview, 712716

separating from algorithms, 722

storing. See Containers

structure. See Containers; class; struct

traversing. See Iteration; Iterators

uniform access and manipulation, 714716. See also STL (Standard Template Library)

Data member, 305, 492493

Data structure. See Data; struct

Data type. See Type

Date and time, 11931194

Date example, See Chapters 67

Deallocating memory, 598600, 10941095. See also delete[]; delete

Debugging, 52, 158, 1219. See also Errors; Testing

arrays and pointers, 656659

assertions, 163

block termination, 161

bugs, 158

character literal termination, 161

commenting code, 159160

compile-time errors, 161

consistent code layout, 160

constructors, 643646

declaring names, 161

displaying the console window, 162

expression termination, 161

finding the last bug, 166167

function size, 160

GUIs, 575577

input data, 166

invariants, 162163

keeping it simple, 160

logic errors, 154156

matching parentheses, 161

naming conventions, 160

post-conditions, 165166

pre-conditions, 163165

process description, 158159

reporting errors, 159

stepping through code, 162

string literal termination, 161

systematic approach, 166167

test cases, 166, 227

testing, 1012

tracing code execution, 162163

transient bugs, 595

using library facilities, 160

widgets, 576577

dec manipulator, 382383, 1174

Decimal digits, isdigit(), 397

Decimal integer literals, 1077

Decimal number system, 381383, 10771078

Deciphering (decryption), example, 969974

Declaration operators, 1099

& reference to, 276279, 1099

* pointer to, 587, 1099

[] array of, 649, 1099

() function of, 113115, 1099

Declarations, 51, 10981099

C++ and C, 1026

classes, 306

collections of. See Header files

constants, 262263

definition, 51, 77, 257, 10981099, 1219

vs. definitions, 259260

entities used for, 261

extern keyword, 259

forward, 261

function, 257258, 1103

function arguments, 272273

function return type, 272273

grouping. See Namespaces

managing. See Header files

need for, 261

order of, 215

parts of, 1098

subdividing programs, 260261

uses for, 1098

variables, 260, 262263

Decrementing ––, 97

iterator, 11411142

pointer, 652

Deep copy, 636

Default constructors, 328329

alternatives for, 329330

for built-in types, 328

initializing objects, 327

need for, identifying, 641

uses for, 328329

#define, 1129

Definitions, 77, 258259, 1219. See also Declarations

C++ and C, 10381040

vs. declarations, 259260

function, 113115, 272273

delete

C++ and C, 1026, 1037

deallocating free store, 10941095

destructors, 601605

embedded systems, 932, 936940

free-store deallocation, 598600

in unary expressions, 1087

delete[], 599, 1087, 10941095

Delphi language, 831

Dependencies, testing, 10021003

Depth-first approach to programming, 6

deque, double ended queue, 1144

<deque>, 1133

Dereference/indirection

*, 594. See also Contents of

[], 118. See also Subscripting

Derivation, classes, 505

Derived classes, 505, 1219

access control, 511

base classes, 11161117

inheritance, 11161117

multiple inheritance, 1117

object layout, 506507

overview, 504506, 11161117

private bases and members, 511

protected bases and members, 511

public bases and members, 511

specifying, 507508

virtual functions, 11171118

Design, 35, 176, 179, 1219

Design for testing, 10111012

Destructors, 601603, 11141115, 1219. See also Constructors

containers, 1148

debugging, 643646

default, 1119

essential operations, 640646

exceptions, 700702

freeing resources, 323, 700702

and free store, 604605

generated, 603

RAII, 700702

virtual, 604605

where needed, 641642

Device drivers, 346

Dictionary examples, 123125, 788

difference_type, 1147

digit, character class, 878, 1179

Digit, word origin, 1077

Dijkstra, Edsger, 827828, 992

Dimensions, matrices, 898901

Direct expression of ideas, ideals, 811812

Dispatch, 504505

Display model, 413414

distance(), 1142

Divide /, 66, 1088

Divide and assign /=, 67, 1090

Divide and conquer, 93

Divide-by-zero error, 201202

divides(), 1164

Domain knowledge, 934

Dot product. See inner_product()

double floating-point type, 63, 6667, 78, 1099

Doubly-linked lists, 613, 725. See also list

draw() example

fill color, 500

line visibility, 500

Shape, 500502

draw_lines() example. See also draw() example

Closed_polyline, 458

Marked_polyline, 475476

Open_polyline, 456

Polygon, 459

Rectangle, 465

Shape, 500502

duration..., 1016, 1185

duration_cast, 1016, 1185

Dynamic dispatch, 504505. See also Virtual functions

Dynamic memory, 935-936, 1094. See also Free store (heap storage)

dynamic_cast, type conversion, 1095

exceptions, 1138

predictability, 932

E

Efficiency

ideals, 9294, 810

vector range checking, 695

Einstein, Albert, 815

Elements. See also vector

numbering, 649

pointers to, 650652

variable number of, 649

Ellipse example, 472474

vs. Circle, 474

Ellipsis ...

arguments (unchecked), 11051106

catch all exceptions, 152

else, in if-statements, 102104

Email example, 855865

Embedded systems

coding standards, 975977, 983

concurrency, 932

containers, 951954

correctness, 929930

delete operator, 932

domain knowledge, 934

dynamic_cast, 932

error handling, 933935

examples of, 926928

exceptions, 932

fault tolerance, 930

fragmentation, 936, 937

free-store, 936940

hard real time, 931

ideals, 932933

maintenance, 929

memory management, 940942

new operator, 932

predictability, 931, 932

real-time constraints, 931

real-time response, 928

reliability, 928

resource leaks, 931

resource limitations, 928

soft real time, 931

special concerns, 928929

Empty

empty(), is container empty? 1150

lists, 729

sequences, 729

statements, 101

Empty statement, 10351036

Encapsulation, 505

Enciphering (Encryption), example, 969974

end()

iterator, 1148

string, 851, 1177

vector, 722

End of file

eof(), 355, 1171

file streams, 366

I/O error, 355

stringstream, 395

End of input, 124

End of line $ (in regular expressions), 873, 1178

Ending programs. See Termination

endl manipulator, 1174

ends manipulator, 1174

English grammar vs. programming grammar, 193194

enum, 318321, 1042. See also Enumerations

Enumerations, 318321, 11071108

enum, 318321, 1042

enumerators, 318321, 11071108

EOF macro, 10531054

eof() stream state, 355, 1171

equal(), 759, 1153

Equal ==, 67, 1088

Equality operators, expressions, 1088

equal_range(), 758, 796

equal_to(), 1163

erase()

list, 742745, 1150

list operations, 615617

string, 851, 1177

vector, 745747

errno, error indicator, 918919, 1182

error() example, 142143

passing multiple strings, 152

Error diagnostics, templates, 683

Error handling. See also Errors; Exceptions

% for floating-point numbers, 230231

catching exceptions, 239241

files fail to open, 389

GUIs, 576

hardware replication, 934

I/O errors. See I/O errors

I/O streams, 1171

mathematical errors, 918919

modular systems, 934935

monitoring subsystems, 935

negative numbers, 229230

positioning in files, 393394

predictable errors, 933

recovering from errors, 239241

regular expressions, 878880

resource leaks, 934

self-checking, 934

STL (Standard Template Library), 11371138

testing for errors, 225229

transient errors, 934

vector resource exceptions, 702

Error messages. See also Reporting errors; error() example; runtime_error

exceptions, printing, 150151

templates, 683

writing your own, 142

Errors, 1219. See also Debugging; Testing

classifying, 134

compile-time, 4850, 134, 136137

detection ideal, 135

error(), 142143

estimating results, 157158

incomplete programs, 136

input format, 6465

link-time, 134, 139140

logic, 134, 154156

poor specifications, 136

recovering from, 239241. See also Exceptions

sources of, 136

syntax, 137138

translation units, 139140

type mismatch, 138139

undeclared identifier, 258

unexpected arguments, 136

unexpected input, 136

unexpected state, 136

Errors, run-time, 134, 140142. See also Exceptions

callee responsibility, 143145

caller responsibility, 142143

hardware violations, 141

reasons for, 144145

reporting, 145146

Essential operations, 640646

Estimating development resources, 177

Estimating results, 157158

Examples

age distribution, 538539

calculator. See Calculator example

Date. See Date example

deciphering, 969974

deleting repeated words, 7173

dictionary, 123125, 788

Dow Jones tracking, 782785

email analysis, 855865

embedded systems, 926928

enciphering (encryption), 969974

exponential function, 527528

finding largest element, 713716, 723724

fruits, 779782

Gaussian elimination, 910911

graphics, 414418, 436

graphing data, 537539

graphing functions, 527528

GUI (graphical user interface), 565569, 573574, 576577

Hello, World! 4546

intrusive containers, 10591065

Lines_window, 565569, 573574, 576577

Link, 613622

list (doubly linked), 613622

map container, 779785

Matrix, 908914

palindromes, 659662

Pool allocator, 940941

Punct_stream, 401405

reading a single value, 359363

reading a structured file, 367376

regular expressions, 880885

school table, 880885

searching, 864872

sequences, 723724

Stack allocator, 942943

TEA (Tiny Encryption Algorithm), 969974

text editor, 734741

vector. See vector example

Widget manipulation, 565569, 12131216

windows, 565569

word frequency, 777779

writing a program. See Calculator example

writing files, 352354

ZIP code detection, 864872

<exception>, 1135

Exceptions, 146150, 11251126. See also Error handling; Errors

bounds error, 149

C++ and C, 1026

catch, 147, 239241, 11251126

cerr, 151152

cout, 151152

destructors, 1126

embedded systems, 932

error messages, printing, 150151

exception, 152, 11381139

failure to catch, 153

GUIs, 576

input, 150153

narrow_cast example, 153

off-by-one error, 149

out_of_range, 149150, 152

overview, 146147

RAII (Resource Acquisition Is Initialization), 1125

range errors, 148150

re-throwing, 702, 1126

runtime_error, 142, 151, 153

stack unwinding, 1126

standard library exceptions, 11381139

terminating a program, 142

throw, 147, 1125

truncation, 153

type conversion, 153

uncaught exception, 153

user-defined types, 1126

vector range checking, 693694

vector resources. See vector

Executable code, 48, 1219

Executing a program, 11, 12001201

exit(), terminating a program, 11941195

explicit constructor, 642643, 1038

Expression, 9495, 10861090

coding standards, 980981

constant expressions, 1093

conversions, 10911093

debugging, 161

grouping (), 95, 867, 873, 876

lvalue, 9495, 1090

magic constants, 96, 143, 232234, 723

memory management, 10941095

mixing types, 99

non-obvious literals, 96

operator precedence, 95

operators, 9799, 10861095

order of operations, 181

precedence, 1090

preserving values, 1091

promotions, 99, 1091

rvalue, 9495, 1090

scope resolution, 1086

type conversion, 99100, 1095

usual arithmetic conversions, 1092

Expression statement, 100

extern, 259, 1033

Extracting text from files, 856861, 864865

F

f/F suffix, 1079

fail() stream state, 355, 1171

Falling through end of functions, 274

false, 1038

Fault tolerance, 930

fclose(), 10531054, 1186

Feature creep, 188, 201, 1219

Feedback, programming, 36

Fields, formatting, 387388

FILE, 10531054

File I/O, 349350

binary I/O, 391

close(), 352

closing files, 352, 1186

converting representations, 374376

modes, 1186

open(), 352

opening files. See Opening files

positioning in files, 393394

reading. See Reading files

writing. See Writing files

Files, 1219. See also File I/O

C++ and C, 10531054

opening and closing, C-style I/O, 1186

fill(), 1157

fill_n(), 1157

Fill color example, 462465, 500

find(), 758761

associative container operations, 1151

finding links, 615617

generic use, 761763

nonmodifying sequence algorithms, 1153

string operations, 851, 1177

find_end(), 1153

find_first_of(), 1153

find_if(), 758, 763764

Finding. See also Matching; Searching

associative container operations, 1151

elements, 758

links, 615617

patterns, 864865, 869872

strings, 851, 1177

fixed format, 387

fixed manipulator, 385, 1174

<float.h>, 894, 1181

Floating-point, 63, 891, 1219

% remainder (modulo), 201

assigning integers to, 892893

assigning to integers, 893

conversions, 1092

fixed format, 387

general format, 387

input, 182, 201202

integral conversions, 10911092

literals, 182, 1079

mantissa, 893

output, formatting, 384385

precision, 386387

and real numbers, 891

rounding, 386

scientific format, 387

truncation, 893

vector example, 120123

float type, 1099

floor(), 917, 1181

FLTK (Fast Light Toolkit), 418, 1204

code portability, 418

color, 451, 465467

current style, obtaining, 500

downloading, 1204

fill, 465

in graphics code, 436

installing, 1205

lines, drawing, 454, 458

outlines, 465

rectangles, drawing, 465

testing, 1206

in Visual Studio, 12051206

waiting for user action, 559560, 569570

flush manipulator, 1174

Flushing a buffer, 240241

Fonts for Graphics example, 468470

fopen(), 10531054, 1186

for-statement, 111113

vs. while, 122

for_each(), 119, 1153

Ford, Henry, 806

Formal arguments. See Parameters

Formatting. See also C-style I/O; I/O streams; Manipulators

See also C-style I/O, 10501054

See also I/O streams, 11721173

case, 397398

See also Manipulators, 11731175

fields, 387388

precision, 386387

whitespace, 397

Fortran language, 821823

array indexing, 899

complex, 920

subscripting, 899

Forward declarations, 261

Forward iterators, 752, 1142

fprintf(), 10511052, 1187

Fragmentation, embedded systems, 936, 937

free(), deallocate, 10431044, 1193

Free store (heap storage)

allocation, 593594

C++ and C, 10431045

deallocation, 598600

delete, 598600, 601605

and destructors. See Destructors

embedded systems, 936940

garbage collection, 600

leaks, 598600, 601605

new, 593594

object lifetime, 1085

Freeing memory. See Deallocating memory

friend, 1038, 1111

from_string() example, 853854

front(), first element, 1149

front_inserter(), 1162

fstream(), 1170

<fstream>, 1134

fstream type, 350352

Fully qualified names, 295297

Function example, 443, 525528

Function, 47, 113117. See also Member functions

accessing class members, 1111

arguments. See Function arguments

in base classes, 504

body, 47, 114

C++ and C, 10281032

callback, GUIs, 556559

calling, 1103

cleaning up, 234235

coding standards, 980981

common style, 490491

debugging, 160

declarations, 117, 1103

definition, 113115, 272, 1219

in derived classes, 501, 505

falling through, 274

formal arguments. See Function parameter (formal argument)

friend declaration, 1111

generic code, 491

global variables, modifying, 269

graphing. See Function example

inline, 316, 1026

linkage specifications, 1106

naming. See Namespaces

nesting, 270

organizing. See Namespaces

overloading, 321323, 526, 1026

overload resolution, 11041105

parameter, 115. See also Function parameter (formal argument)

pointer to, 10341036

post-conditions, 165166

pre-conditions, 163165

pure virtual, 1221

requirements, 153. See also Pre-conditions

return, 113115, 272273, 1103

return type, 47, 272273

standard mathematical, 528, 11811182

types as parameters. See Template

uses for, 115116

virtual, 10341036. See also Virtual functions

Function activation record, 287

Function argument. See also Function parameter (formal argument); Parameters

checking, 284285

conversion, 284285

declaring, 272273

formal. See Parameters

naming, 273

omitting, 273

passing. See Function call

Function call, 285

call stack, 290

expression() call example, 287290

function activation record, 287

history of, 820

memory for, 591592

() operator, 766

pass by const reference, 276278, 281284

pass by non-const reference, 281284

pass by reference, 279284

pass by value, 276, 281284

recursive, 289

stack growth, 287290. See also Function activation record

temporary objects, 282

Function-like macros, 10561058

Function member

definition, 305306

same name as class. See Constructors

Function objects, 765767

() function call operator, 766

abstract view, 766767

adaptors, 1164

arithmetic operations, 1164

parameterization, 767

predicates, 767768, 1163

Function parameter (formal argument)

... ellipsis, unchecked arguments, 11051106

pass by const reference, 276278, 281284

pass by non-const reference, 281284

pass by reference, 279284

pass by value, 276, 281284

temporary objects, 282

unused, 272

Function template

algorithms, 682683

argument deduction, 689690

parameterized functions, 682683

<functional>, 1133, 1163

Functional cast, 1095

Functional programming, 823

Fused multiply-add, 904

G

Gadgets. See Embedded systems

Garbage collection, 600, 938939

Gaussian elimination, 910911

gcount(), 1172

general format, 387

general manipulator, 385

generate(), 1157

generate_n(), 1157

Generic code, 491

Generic programming, 682683, 816, 1219

Geometric shapes, 427

get(), 1172

getc(), 1052, 1191

getchar(), 1053, 1191

getline(), 395396, 851, 855, 1172

gets(), 1052

C++ alternative >>, 1053

dangerous, 1052

scanf(), 1190

get_token() example, 196

GIF images, 480482

Global scope, 267, 270, 1082

Global variables

functions modifying, 269

memory for, 591592

order of initialization, 292294

Going out of scope, 268269, 291

good() stream state, 355, 1171

GP. See Generic programming

Grammar example

alternation, patterns, 194

English grammar, 193194

Expression example, 197200, 202203

parsing, 190193

repetition, patterns, 194

rules vs. tokens, 194

sequencing rules, 195

terminals. See Tokens

writing, 189, 194195

Graph example. See also Grids, drawing

Axis, 424426

coordinates, 426427

drawing, 426427

points, labeling, 474476

Graph.h, 421422

Graphical user interfaces. See GUIs (graphical user interfaces)

Graphics, 412. See also Graphics example; Color example; Shape example

displaying, 479482

display model, 413414

drawing on screen, 423424

encoding, 480

filling shapes, 431

formats, 480

geometric shapes, 427

GIF, 480482

graphics libraries, 481482

graphs, 426427

images from files, 433434

importance of, 412413

JPEG, 480482

line style, 431

loading from files, 433434

screen coordinates, 419420

selecting a sub-picture from, 480

user interface. See GUIs (graphical user interfaces)

Graphics example

Graph.h, 421422

GUI system, giving control to, 423

header files, 421422

main(), 421422

Point.h, 444

points, 426427

Simple_window.h, 444

wait_for_button(), 423

Window.h, 444

Graphics example, design principles

access control. See Access control

attach() vs. add(), 491492

class diagram, 505

class size, 489490

common style, 490491

data modification access, 492493

generic code, 491

inheritance, interface, 513514

inheritances, implementation, 513514

mutability, 492493

naming, 491492

object-oriented programming, benefits of, 513514

operations, 490491

private data members, 492493

protected data, 492493

public data, 492493

types, 488490

width/height, specifying, 490

Graphics example, GUI classes, 442444. See also Graphics example, interfaces

Button, 443

In_box, 443

Menu, 443

Out_box, 443

Simple_window, 422424, 443

Widget, 561563, 12091210

Window, 443, 12101212

Graphics example, interfaces, 442443. See also Graphics example, GUI classes

Axis, 424426, 443, 529532

Circle, 469472, 497

Closed_polyline, 456458

Color, 450

Ellipse, 472474

Function, 443, 524528

Image, 443, 479482

Line, 445448

Line_style, 452455

Lines, 448450, 497

Mark, 478479

Marked_polyline, 474476

Marks, 476477, 497

Open_polyline, 455456, 497

Point, 426427, 445

Polygon, 427428, 458460, 497

Rectangle, 428431, 460465, 497

Shape, 444445, 449, 493494, 513514

Text, 431433, 467470

Graphing data example, 538546

Graphing functions example, 520524, 532537

Graph_lib namespace, 421422

greater(), 1163

Greater than >, 67, 1088

Greater than or equal >=, 1088

greater_equal(), 1163

Green marginal alerts, 3

Grids, drawing, 448449, 452455

Grouping regular expressions, 867, 873, 876

Guarantees, 701702

Guidelines. See Ideals

GUIs (graphical user interfaces), 552553. See also Graphics example, GUI classes

callback functions, 556559

callback implementation, 12081209

cb_next() example, 556559

common problems, 575577

control inversion, 569570

controls. See Widget example

coordinates, computer screens, 419420

debugging, 575577

error handling, 576

examples, 565569, 573574, 576577

exceptions, 576

FLTK (Fast Light Toolkit), 418

layers of code, 557

next() example, 558559

pixels, 419420

portability, 418

standard library, 418419

toolkit, 418

vector_ref example, 12121213

vector of references, simulating, 12121213

wait loops, 559560

wait_for_button() example, 559560

waiting for user action, 559560, 569570

Widget example, 561569, 12091210, 12131216

Window example, 565569, 12101212

GUI system, giving control to, 423

H

.h file suffix, 46

Half open sequences, 119, 721

Hard real-time, 931, 981982

Hardware replication, error handling, 934

Hardware violations, 141

Hashed container. See unordered_map

Hash function, 785786

Hashing, 785

Hash tables, 785

Hash values, 785

Header files, 46, 1219

C standard library, 11351136

declarations, managing, 264

definitions, managing, 264

graphics example, 421422

including in source files, 264266, 1129

multiple inclusion, 1059

standard library, 11331134

Headers. See Header files

Heap algorithm, 1160

Heap memory, 592, 935936, 1084, 1160. See also Free store (heap storage)

Hejlsberg, Anders, 831

“Hello, World!” program, 4547

Helper functions

== equality, 333

!= inequality, 333

class interfaces, 332334

Date example, 309310, 332333

namespaces, 333

validity checking date values, 310

hex manipulator, 382383, 1174

Hexadecimal digits, 397

Hexadecimal number system, 381383, 10771078

Hiding information, 1220

Hopper, Grace Murray, 824825

Hyperbolic cosine, cosh(), 918

Hyperbolic sine, sinh(), 918, 1182

Hyperbolic tangent, tanh(), 917

I

I/O errors

bad() stream state, 355

clear(), 355358

end of file, 355

eof() stream state, 355

error handling, 1171

fail() stream state, 355

good() stream state, 355

ios_base, 357

recovering from, 355358

stream states, 355

unexpected errors, 355

unget(), 355358

I/O streams, 11681169

>> input operator, 855

<< output operator, 855

cerr, standard error output stream, 151152, 1169, 1189

cin standard input, 347

class hierarchy, 855, 11701171

cout standard output, 347

error handling, 1171

formatting, 11721173

fstream, 388390, 393, 1170

get(), 855

getline(), 855

header files, 1134

ifstream, 388390, 1170

input operations, 1172

input streams, 347349

iostream library, 347349, 11681169

istream, 347349, 11691170

istringstream, 1170

ofstream, 388390, 1170

ostream, 347349, 11681169

ostringstream, 388390, 1170

output operations, 1173

output streams, 347349

standard manipulators, 382, 11731174

standard streams, 1169

states, 1171

stream behavior, changing, 382

stream buffers, streambufs, 1169

stream modes, 1170

string, 855

stringstream, 395, 1170

throwing exceptions, 1171

unformatted input, 1172

IBM, 823

Ichbiah, Jean, 832

IDE (interactive development environment), 52

Ideals

abstraction level, 812813

bottom-up approach, 811

class interfaces, 323

code structure, 810811

coding standards, 976977

consistency, 814815

correct approaches, 811

correctness, 810

definition, 1219

direct expression of ideas, 811812

efficiency, 810

embedded systems, 932933

importance of, 8

KISS, 815

maintainability, 810

minimalism, 814815

modularity, 813814

overview, 808809

performance, 810

software, 3437

on-time delivery, 810

top-down approach, 811

Identifiers, 1081. See also Names

reserved, 7576. See also Keywords

if-statements, 102104

#ifdef, 10581059

#ifndef, 10581059

ifstream type, 350352

imag(), imaginary part, 920, 1183

Image example, 443, 479482

Images. See Graphics

Imaginary part, 920

Immutable values, class interfaces, 330332

Implementation, 1219

class, 306308

inheritance, 513514

programs, 36

Implementation-defined feature, 1075

Implicit conversions, 642643

in mode, 389, 1170

In_box example, 443, 563564

In-class member definition, 1112

#include, 46, 264266, 11281129

Include guard, 1059

includes(), 1159

Including headers, 1129. See also #include

Incrementing ++, 66, 721

iterators, 721, 750, 11401141

pointers, 651652

variables, 7374, 9798

Indenting nested code, 271

Inequality != (not equal), 67, 1088, 1101

complex, 919, 1183

containers, 1151

helper function, 333

iterators, 721, 1141

string, 67, 851, 1176

Infinite loop, 1219

Infinite recursion, 198, 1220

Information hiding, 1220

Information processing, 32

Inheritance

class diagram, 505

definition, 504

derived classes, 11161117

embedded systems, 951954

history of, 834

implementation, 513514

interface, 513514

multiple, 1117

pointers vs. references, 612613

templates, 686687

Initialization, 6973, 1220

{} initialization notation, 83

arrays, 596598, 654656

constants, 262, 329330, 1099

constructors, 310312

Date example, 309312

default, 263, 327, 1085

invariants, 313314, 701702

menus, 571

pointers, 596598, 657

pointer targets, 596598

Token example, 184

initializer_list, 630

inline, 1037

Inline

functions, 1026

member functions, 316

inner_product(), 759. See also Dot product

description, 774775

generalizing, 775776

matrices, 904

multiplying sequences, 1184

standard library, 759, 770

inplace_merge(), 1158

Input, 6062. See also Input >>; I/O streams

binary I/O, 390393

C++ and C, 10521053

calculator example, 179, 182, 185, 201202, 206208

case sensitivity, 64

cin, standard input stream, 61

dividing functions logically, 359362

files. See File I/O

format errors, 6465

individual characters, 396398

integers, 383384

istringstream, 394

line-oriented input, 395396

newline character n, 6162, 64

potential problems, 358363

prompting for, 61, 179

separating dialog from function, 362363

a series of values, 356358

a single value, 358363

source of exceptions, 150153

stringstream, 395

tab character , 64

terminating, 6162

type sensitivity, 6465

whitespace, 64

Input >>, 61

case sensitivity, 64

complex, 920, 1183

formatted input, 1172

multiple values per statement, 65

strings, 851, 1177

text input, 851, 855

user-defined, 365

whitespace, ignoring, 64

Input devices, 346347

Input iterators, 752, 1142

Input loops, 365367

Input/output, 347349. See also Input; Output

buffering, 348, 406

C++ and C. See stdio

computation overview, 91

device drivers, 346

errors. See I/O errors

files. See File I/O

formatting. See Manipulators; printf()

irregularity, 380

istream, 347354

natural language differences, 406

ostream, 347354

regularity, 380

streams. See I/O streams

strings, 855

text in GUIs, 563564

whitespace, 397, 398405

Input prompt >, 223

Inputs, testing, 1001

Input streams, 347349. See also I/O streams

insert()

list, 615617, 742745

map container, 782

string, 851, 1150, 1177

vector, 745747

inserter(), 1162

Inserters, 11621163

Inserting

list elements, 742745

into strings, 851, 1150, 1177

vector elements, 745747

Installing

FLTK (Fast Light Toolkit), 1205

Visual Studio, 1198

Instantiation, templates, 681, 11231124

int, integer type, 6667, 78, 1099

bits in memory, 78, 955

Integers, 7778, 890891, 1220

assigning floating-point numbers to, 893

assigning to floating-point numbers, 892893

decimal, 381383

input, formatting, 383384

largest, finding, 917

literals, 1077

number bases, 381383

octal, 381383

output, formatting, 381383

reading, 383384

smallest, finding, 917

Integral conversions, 10911092

Integral promotion, 1091

Interactive development environment (IDE), 52

Interface classes. See Graphics example, interfaces

Interfaces, 1220

classes. See Class interfaces

inheritance, 513514

user. See User interfaces

internal manipulator, 1174

Intrusive containers, example, 10591065

Invariants, 313314, 1220. See also Post-conditions; Pre-conditions

assertions, 163

Date example, 313314

debugging, 162163

default constructors, 641

documenting, 815

invention of, 828

Polygon example, 460

Invisible. See Transparency

<iomanip>, 1134, 1173

<ios>, 1134, 1173

<iosfwd>, 1134

iostream

buffers, 406

C++ and C, 1050

exceptions, 1138

library, 347349

<iostream>, 1134, 1173

Irregularity, 380

is_open(), 1170

isalnum() classify character, 397, 1175

isalpha() classify character, 247, 397, 1175

iscntrl() classify character, 397, 1175

isdigit() classify character, 397, 1175

isgraph() classify character, 397, 1175

islower() classify character, 397, 1175

isprint() classify character, 397, 1175

ispunct() classify character, 397, 1175

isspace() classify character, 397, 1175

istream, 347349, 11691170

>>, text input, 851, 1172

>>, user-defined, 365

binary I/O, 390393

connecting to input device, 1170

file I/O, fstream, 349354, 1170

get(), get a single character, 397

getline(), 395396, 1172

stringstreams, 395

unformatted input, 395396, 1172

using together with stdio, 1050

<istream>, 1134, 11681169, 1173

istream_iterator type, 790793

istringstream, 394

isupper() classify character, 397, 1175

isxdigit() classify character, 397, 1175

Iteration. See also Iterators

control variables, 110

definition, 1220

example, 737741

linked lists, 727729, 737741

loop variables, 110111

for-statements, 111113

strings, 851

through values. See vector

while-statements, 109111

iterator, 1147

<iterator>, 1133, 1162

Iterators, 721722, 11391140, 1220. See also STL iterators

bidirectional iterator, 752

category, 752, 11421143

containers, 11431145, 1148

empty list, 729

example, 737741

forward iterator, 752

header files, 11331134

input iterator, 752

operations, 721, 11411142

output iterator, 752

vs. pointers, 1140

random-access iterator, 752

sequence of elements, 11401141

iter_swap(), 1157

J

Japanese age distribution example, 538539

JPEG images, 480482

K

Kernighan, Brian, 838839, 10221023

key_comp(), 1152

key_compare, 1147

key_type, 1147

Key, value pairs, containers for, 776

Keywords, 10371038, 10811082

KISS, 815

Knuth, Don, 808

K&R, 838, 1022

L

l/L suffix, 1077

l, “lowercase character,” regex, 873, 1179

L, “not lowercase character,” regex, 874, 1179

Label

access control, 306, 511

case, 106108

graph example, 529532

of statement, 1096

Lambda expression, 560561

Largest integer, finding, 917

Laws of optimization, 931

Layers of code, GUIs, 557

Layout rules, 979, 1034

Leaks, memory, 598600, 601605, 937

Leap year, 309

left manipulator, 1174

Legal programs, 1075

length(), 851, 1176

Length of strings, finding, 851, 1046, 1176

less(), 1163

Less than <, 1088

Less than or equal <=, 67, 1088

less_equal(), 1163

Letters, identifying, 247, 397

lexical_cast, 855

Lexicographical comparison

<= comparison, 1176

< comparison, 1176

>= comparison, 1176

> comparison, 1176

< comparison, 851

C-style strings, 1046

lexicographical_compare(), 1162

Libraries, 51, 1220. See also Standard library

role in debugging, 160

uses for, 177

Lifetime, objects, 10851086, 1220

Limit macros, 1181

<limits>, 894, 1135, 1180

Limits, 894895

<limits.h>, 894, 1181

Linear equations example, 908914

back_substitution(), 910911

classic_elimination(), 910911

Gaussian elimination, 910911

pivoting, 911912

testing, 912914

Line comment //, 45

Line example, 445447

vs. Lines, 448

Line-oriented input, 395396

Lines example, 448450, 497

vs. Line, 448

Lines (graphic), drawing. See also Graphics; draw_lines()

on graphs, 529532

line styles, 452455

multiple lines, 448450

single lines, 445447

styles, 431, 454

visibility, 500

Lines (of text), identifying, 736737

Line_style example, 452455

Lines_window example, 565569, 573574, 576577

Link example, 613622

Link-time errors. See Errors, link-time

Linkage convention, C, 1033

Linkage specifications, 1106

Linked lists, 725. See also Lists

Linkers, 51, 1220

Linking programs, 51

Links, 613615, 620622, 725

Lint, consistency checking program, 836

Lisp language, 825826

list, 727, 11461151

{} initialization notation, 83

add(), 615617

advance(), 615617

back(), 737

erase(), 615617, 742745

find(), 615617

insert(), 615617, 742745

operations, 615617

properties, 741742

referencing last element, 737

sequence containers, 1144

subscripting, 727

<list>, 1133

Lists

containers, 1150

doubly linked, 613, 725

empty, 729

erasing elements, 742745

examples, 613615, 734741

finding links, 615617

getting the nth element, 615617

inserting elements, 615617, 742745

iteration, 727729, 737741

link manipulation, 615617

links, examples, 613615, 620622, 726

operations, 726727

removing elements, 615617

singly linked, 612613, 725

this pointer, 618620

Literals, 62, 1077, 1220

character, 161, 10791080

decimal integer, 1077

in expressions, 96

f/F suffix, 1079

floating-point, 1079

hexadecimal integer, 1077

integer, 1077

l/L suffix, 1077

magic constants, 96, 143, 232234, 723

non-obvious, 96

null pointer, 0, 1081

number systems, 10771079

octal integer, 1077

special characters, 10791080

string, 161, 1080

termination, debugging, 161

for types, 63

u/U suffix, 1077

unsigned, 1077

Local (automatic) objects, lifetime, 1085

Local classes, nesting, 270

Local functions, nesting, 270

Local scope, 267, 1083

Local variables, array pointers, 658

Locale, 406

<locale>, 1135

log(), 918, 1182

log10(), 918, 1182

Logic errors. See Errors, logic

Logical and &&, 1089, 1094

Logical operations, 1094

Logical or ||, 1089, 1094

logical_and(), 1163

logical_not(), 1163

logical_or(), 1163

Logs, graphing, 528

long integer, 955, 1099

Look-ahead problem, 204209

Loop, 110111, 112, 1220

examples, parser, 200

infinite, 198, 1219

testing, 10051006

variable, 110111, 112

Lovelace, Augusta Ada, 832

lower, 878, 1179

lower_bound(), 796, 1152, 1158

Lower case. See Case (of characters)

Lucent Bell Labs, 838

Lvalue, 9495, 1090

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.20.224.107