floating-point display precision, 1082–1083

flushing buffers, 1075–1076

formatting data types, 1076–1078

methods, 1071–1075

number base display, 1078–1079

printing trailing zeros/decimal points, 1083–1090

creating, 523

defined, 13, 36

functions. See function objects

ifstream, 1116–1119

ofstream, 1115–1119

ostringstream, 1142–1145

passing by reference, 770

passing by value, 770

pointers, 665–670

reference variables, 401–405

returning, 662–664, 770–771

const objects, 662–665

non-const objects, 663

stream, 1067

string, 965

subobjects, 797

this pointer, 539–546

valarray, 1045–1051

vector, 979–991, 1045–1051

adding elements to, 982–983

past-the-end iterators, 981–982

removing ranges of, 982

shuffling elements in, 987

sorting, 987

vect1.cpp example, 980–981

vect2.cpp sample program, 984–986

vect3.cpp sample program, 988–991

oct manipulators, 1078–1079, 1090–1091

octal numbers, 1215–1216

ofstream objects, 290, 1115–1119

one definition rule, 475

one-dimensional arrays, 244

OOP (object-oriented programming), 13, 506–507, 512, 1207

classes, 47–48

client/server model, 520

overview, 13–14

open namespaces, 485

open() method, 291–293, 967, 1119, 1122–1125

opening files, 1124–1125

multiple, 1119

operands, 97

operator functions, 565

operator overloading, 37, 564–566

addition operator (+), 569–572

cin object input, 1095–1097

example, 565–569

mytime0.cpp, 566

mytime0.h, 566

usetime0.cpp, 568–569

left shift operator (<), 581–587

member versus nonmember functions, 587–588

multiplication operator (*), 574–578

operator functions, 565

operator*(), 574–578

operator+(), 569–572

operator-(), 574–578

operator<<(), 581–585, 587

restrictions, 573–574

subtraction operator (-), 574–578

vector class, 588–590, 600

adding vectors, 590

declaring, 591–592

displacement vectors, 589

implementation comments, 602

member functions, 592, 597

multiple representations, 599

overloaded arithmetic operators, 599–600

overloading overloaded operators, 601

Random Walk sample program, 602, 605–606

state members, 597–599

with classes, string, 965

operator*() function, 574–578

operator+() function, 569–572

operator+() method, 1266

operator-() function, 574–578

operators, 1235

addition operator (+), overloading, 569–572

alternative tokens, 1222

arithmetic operators, 97–99

associativity, 99–100

division (/), 100–101

modulus (%), 101–102

order of precedence, 99–100

assignment (=), 43–44, 644, 767–768, 772–775

custom definitions, 645–646

enumerator value ranges, 153

enumerator values, setting, 152

overloading, 652–658

potental problems, 645

strings, 133–134

structures, 145–146

when to use, 644

associativity, 1231

examples, 1234

table of, 1232–1234

binary operators, 601, 1234

bitwise operators, 1235

alternative representations, 1240

logical bitwise operators, 1237–1240

shift operators, 1235–1237

testing bit values, 1241–1242

toggling, 1241

turning bits off, 1241

turning bits on, 1241

combination assignment operators, 211–212

comma, 214–217

example, 214–216

precedence, 217

concatenation (+), strings, 133–134

conditional (?::), 273–274

const_cast, 944

decrement (—), 207–208

pointers, 210–211

postfixing, 209–210

prefixing, 209–210

deferencing (*), pointers, 171–172

defined, 70

delete, 163–164, 180–183, 400, 454, 476–477, 668

dereferencing (*), 155–159

dynamic cast, 934–943

functor equivalents for arithmetic, logical, and relational operators, 1031–1032

increment (++), 197, 207–208

pointers, 210–211

postfixing, 209–210

prefixing, 209–210

left shift operator (<<)

overloading, 581–587, 676

literal operators, 1204

member dereferencing operators, 1242–1246

multiplication operator (*), overloading, 574–578

new, 180–182, 454, 476–482, 668

bad_alloc exceptions, 921

constructors, 659–661, 677–678

dynamic arrays, 164–167

dynamic structures, 178–180

free store, 183

memory allocation, 160–162

placement new, 671–676

reference variables, 400

operator functions, 565

operator*(), 574–578

operator+(), 569–572

operator-(), 574–578

operator<<(), 581–587

overloading, 101, 564–565

addition operator (+), 569–572

assignment operator, 652–658

example, 565–569

left shift operator (<<), 581–587, 676

member versus nonmember functions, 587–588

multiplication operator (*), 574–578

operator functions, 565

overloading overloaded operators, 601

restrictions, 573–574

subtraction operator (-), 574–578

precedence, 1231

examples, 1234

table of, 1232–1234

reference operator (&), 383–386

reinterpret_cast, 946

relational operators, 217–220

C-style strings, comparing, 220–223

equality operator (==), 218–220

string class strings, comparing, 223–224

table of, 217

scope resolution (::), 467

scope-resolution (::), 514

scope-resolution operator, 1332

sizeof, 71–73

static_cast, 945–946

Перейти на страницу:

Все книги серии Developer's Library

Похожие книги