O

object, 46, 75

automatic, 255, 280

function, 553

is not polymorphic, 569

local static, 255, 281

temporary, 247

object cleanup, see destructor

object creation

constructor, 452

order of construction, 456

derived objects, 581, 582

multiple base classes, 732

virtual base classes, 745

order of destruction, 485

derived objects, 587

multiple base classes, 733

virtual base classes, 747

object file, 68

object lifetime, 254, 281

and destructor, 485

compared to scope, 254

object-oriented programming, 285, 302, 622

key ideas in, 558–560

oct manipulator, 827

octal, literal (0num), 38

octal escape sequence ( nn), 40

off-the-end iterator, 97, 394, 425

istream_iterator, 408

off-the-end pointer, 125

ofstream, 285, 293–299

see also ostream

close, 294

constructor, 293

file marker, 838

file mode, 296

combinations, 298

example, 299

file random access, 838

off_type, 839

open, 293

pos_type, 839

random IO sample program, 840

seek and tell members, 838–842

open, 293

open_file, example of, 370, 383

open_file program, 299

operand, 148, 189

order of evaluation

comma operator, 172

conditional operator, 172

logical operator, 172

operator, 148, 189

sizeof, 167

typeid, 775, 807

addition (+), 150

string, 86

iterator, 101, 313

pointer, 123

address-of (&), 115

arrow (–>), 164

class member access, 445

assignment (=), 13, 30, 159

and conversion, 179

and equality, 161

container, 328

multiple inheritance, 737

pointer, 120

string, 86

to signed, 37

to unsigned, 37

yields lvalue, 160

binary, 148, 188

bitwise AND (&), 156

bitwise exclusive or (^), 156

bitwise not (~), 155

bitwise OR (|), 156

bitwise OR (|), example, 290

call (()), 30, 226

comma (,), 168

operand order of evaluation, 172

comma (,), example, 289

compound assginment (e.g.,+=), iterator, 313

compound assignment (e.g.,+=), 13, 30, 161

string, 86

arithmetic, 162

bitwise, 162

conditional (?:), 165

operand order of evaluation, 172

decrement (--)

iterator, 312

prefix yields lvalue, 162

reverse iterator, 412

dereference (*), 98

and increment, 163

iterator, 98

on map yields pair, 362

pointer, 119

yields lvalue, 99, 120

division (/), 150

dot (.), 25, 30

class member access, 445

equality (==), 30, 154

string, 85

algorithm, 421

container, 322

container adaptor, 350

iterator, 98, 312

string, 347

greater-than (>), 30, 153

greater-than-or-equal (>=), 30, 153

increment (++), 13, 30

and dereference, 163

iterator, 98, 312

pointer, 114

prefix yields lvalue, 162

reverse iterator, 412

inequality (!=), 30, 154

container, 322

container adaptor, 350

iterator, 98, 312

string, 347

input (>>), 8, 30

Sales_item, 516

istream_iterator, 408

string, 81

precedence and associativity, 158

left-shift (<<), 155, 190

less-than (<), 30, 153

used by algorithm, 420

less-than-or-equal (<=), 13, 30, 153

logical AND (&&), 152

operand order of evaluation, 172

logical NOT (!), 153

logical OR (||), 152

operand order of evaluation, 172

modulus (%), 151

multiplication (*), 150

output (<<), 7, 30

bitset, 106

ostream_iterator, 408

string, 81

precedence and associativity, 158

overloaded, 189, 482, 503

pointer to member

arrow (–>*), 783

dot (.*), 783

right-shift (>>), 155, 190

scope (::), 8, 30, 78

class member, 85, 445

container defined type, 317

member function definition, 262

to override name lookup, 449

shift, 155, 190

sizeof, 167

subscript ([ ])

bitset, 105

deque, 325

map, 363

string, 87

vector, 94, 325

and multi-dimensioned array, 142

and pointer, 124

array, 113

valid subscript range, 88

yields lvalue, 88

subtraction (-), 150

iterator, 101, 313

pointer, 123

unary, 148, 189

unary minus (-), 150

unary plus (+), 150

operator alternative name, 46

operator delete function, 760, 806

compared to deallocate, 761

compared to delete expression, 760

operator delete member, 764

and inheritance, 764

example, 769

CachedObj, 770

interface, 764

operator delete [] member, 765

operator new function, 760, 806

compared to allocate, 761

compared to new expression, 760

operator new member, 764

example, 769

CachedObj, 769

interface, 764

operator new [] member, 765

operator overloading, see overloaded operator

options to main, 243

order of construction, 456, 749

derived objects, 581, 582

multiple base classes, 732

virtual base classes, 746

order of destruction, 485, 749

derived objects, 587

multiple base classes, 733

virtual base classes, 747

order of evaluation, 149, 189

comma operator, 172

conditional operator, 172

logical operator, 172

ordering, strict weak, 360, 389

OrQuery, 609

definition, 618

eval function, 619

ostream, 6, 29, 285

see also manipulator

condition state, 287

floatfield member, 831

flushing output buffer, 290

format state, 825

inheritance hierarchy, 740

no containers of, 310

no copy or assign, 287

not flushed if program crashes, 292

output (<<), 7

precedence and associativity, 158

precision member, 829

seek and tell members, 838

tie member, 292

unsetf member, 831

ostream_iterator, 407, 425

and class type, 410

constructors, 408

limitations, 411

operations, 410

output iterator, 417

output operator (<<), 408

used with algorithms, 411

ostringstream, 285, 299–301

see also ostream

str, 301

out (file mode), 296

out_of_range, 219, 325

out_of__stock, 699

output, standard, 6

output (<<), 7, 30

bitset, 106

ostream_iterator, 408

string, 81, 108

overloaded operator, 513

formatting, 514

must be nonmember, 514

precedence and associativity, 158

Sales_item, 514

output iterator, 416, 425

overflow, 150

overflow_error, 219

overload resolution, see function matching

overloaded function, 265, 281

using declarations, 728

using directive, 729

compared to redeclaration, 266

compared to template specialization, 673

friend declaration, 467

linkage directive, 803

namespaces, 727

scope, 268

virtual, 593

overloaded member function, 436

on const, 442

overloaded operator, 189, 482, 503

<< (output operator), 513

* (dereference), 524

& (address-of), 511

–> (arrow operator), 525

[ ] (subscript), 522

reference return, 522

() (call operator), 530

= (assignment), 476, 483, 520

and copy constructor, 484

check for self-assignment, 490

Message, 490

reference return, 483, 521

rule of three, 485

use counting, 495, 498

valuelike classes, 501

>> (input operator), 515

error handling, 516–517

must be nonmember, 514

<< (output operator)

formatting, 514

must be nonmember, 514

Sales_item, 514

&& (logical AND), 511

|| (logical OR), 511

, (comma operator), 511

addition (+), Sales_item, 517

ambiguous, 550

arithmetic operators, 517

as virtual function, 615

binary operator, 508

candidate functions, 549

compound assignment (e.g.,+=), 511

Sales_item, 521

consistency between relational and equality operators, 520

definition, 482, 506

design, 510–513

equality operators, 512, 518

explicit call to, 509

explicit call to postfix operators, 529

function matching, 547–551

member and this pointer, 483

member vs. nonmember function, 508, 512

postfix increment (++) and decrement (--) operators, 528

precedence and associativity, 507

prefix increment (++) and decrement (--) operators, 527

relational operators, 511, 520

require class-type parameter, 507

unary operator, 508

overloading, see overloaded function

operator, see overloaded operator

P

pair, 356, 388

as return type from map::insert, 365

as return type from set::insert, 373

default constructor, 357

definition, 356

initialization, 356

make_pair, 358

operations, 357

public data members, 357

Panda, 731

virtual inheritance, 741

parameter, 226, 227, 281

array and buffer overflow, 242

array type, 238–244

C-style string, 242

const, 231

const reference, 235

overloading, 275

ellipsis, 244

function pointer, 278

linkage directive, 804

initialization of, 229

iterator, 238, 242

library container, 237

lifetime, 255

local copy, 230

matching, 229

ellipsis, 244

template specialization, 673

with class type conversion, 541

multi-dimensioned array, 241

nonconst reference, 232

nonreference type, 230

uses copy constructor, 478

of member function, 260

vector type, 237

passing, 229

pointer to const, 231

overloading, 275

pointer to function, 278

linkage directive, 804

pointer to nonconst, 231

pointer type, 231, 239

reference

to array type, 240

to pointer, 236

template, see template parameter

and main, 243

type checking

and template argument, 638

of reference to array, 240

parameter list, 3, 29, 226, 228

member function definition, 446

parentheses, override precedence, 169

partial specialization, 678, 684

partial_sort, 818

partial_sort_copy, 818

partial_sum, 824

partition, 817

placement new, 761, 807

compared to construct, 762

plus<T>, 534

pointer, 114, 114–126, 146

array, 122

arrow (–>), 164

as initializer of vector, 140

as parameter, 231

assignment, 120

char*, see C-style string

class member copy control, 492–501

copy constructor, 480

destructor, 485

strategies, 499

compared to iterator, 114

compared to reference, 121

const, 128

const pointer to const, 129

container constructor from, 308

conversion from derived to base, 567

conversion from derived to multiple base, 734

conversion to bool, 182

conversion to void, 181

dangling, 176, 188

synthesized copy control, 494

declaration style, 116–117

definition, 115

delete, 176

dynamic_cast, example, 773

function returning, 228

implicit this, 260, 281, 431, 440

in overloaded operator, 508

static member functions, 469

initialization, 117–119

is polymorphic, 569

multi-dimensioned array, 143

new, 174

null, 118

off-the-end, 125

pitfalls with generic programs, 671

reference parameter, 236

relational operator, 132

return type and local variable, 249

smart, 495, 503, 553

handle class, 599

overloaded –> (arrow operator) and * (dereference), 524

overloaded (++) and (*), 526

subscript operator, 124

to pointer, 122

typedef, 129

typeid operator, 776

uninitialized, 117

volatile, 800

pointer arithmetic, 123, 146

pointer to const, 127

argument, 231

conversion from nonconst, 127

parameter, 231

overloading, 275

pointer to function, 276–279

definition, 276

exception specifications, 711

function returning, 228

initialization, 277

linkage directive, 803

overloaded functions, 279

parameter, 278

return type, 278

typedef, 276

pointer to member, 780, 807

and typedef, 783

arrow (–>*), 783

definition, 781

dot (.*), 783

function pointer, 782

function table, 785

pointer to nonconst

argument, 231

parameter, 231

polymorphism, 558, 622

compile time polymorphism via templates, 624

run time polymorphism in C++, 569

pop

priority_queue, 352

queue, 352

stack, 351

pop_back, sequential container, 326

pop_front, sequential container, 326

portable, 797

postfix decrement (--)

overloaded operator, 528

yields rvalue, 163

postfix increment (++)

and dereference, 163

overloaded operator, 528

precedence, 124, 146, 149, 168, 189

of assignment, 160

of conditional, 166

of dot and derefernece, 164

of increment and dereference, 163

of IO operator, 158

of pointer to member and call operator, 782

overloaded operator, 507

pointer parameter declaration, 241

precedence table, 170

predicate, 402, 425

prefix decrement (--), 163

overloaded operator, 527

yields lvalue, 162

prefix increment (++)

and dereference, 163

overloaded operator, 527

yields lvalue, 162

preprocessor, 70, 75

directive, 7, 29

macro, 221, 224

variable, 71

prev_permutation, 821

preventing copies of class objects, 481

print_total, 559

explained, 568

printable character, 88

printValues program, 240, 242, 243

priority_queue, 348, 354

constructors, 349

relational operator, 350

private

class, 496

copy constructor, 481

inheritance, 571

member, 75, 474

private access label, 65, 432

inheritance, 561

private inheritance, 622

program

factorial, 250

find_val, 234

gcd, 226

isShorter, 235

make_plural, 248

open_file, 299

printValues, 240, 242, 243

ptr_swap, 237

rgcd, 250

swap, 233, 245

vector capacity, 331

book finding

using equal_range, 379

using find, 377

using upper_bound, 378

bookstore, 26

bookstore exception classes, 698

CachedObj, 766

duplicate words, 400–404

revisited, 531

find last word, 414

GT6, 403

Handle class, 667

int instantiation, 668

operations, 668

Sales_item instantiation, 669

isShorter, 403

message handling classes, 486

Query

design, 609–611

interface, 610

operations, 607

Queue, 648

copy_elems member, 652

destroy member, 651

pop member, 651

push member, 652

random IO example, 840

restricted word count, 374

Sales_item handle class, 599

Screen class template, 655

TextQuery, 383

class definition, 382

design, 380

interface, 381

vector, capacity, 331

vowel counting, 200

word count, 363

word transformation, 370

ZooAnimal class hierarchy, 731

programmer-defined header, 67–72

programming

generic, 95, 624

object-oriented, 285, 302, 622

promotion, integral, 180, 189

protected, inheritance, 571, 622

protected access label, 562, 622

protected keyword, 562

prototype, function, 251, 281

ptr_swap program, 237

ptrdiff_t, 123, 146

public

inheritance, 571, 622

member, 75, 474

public access label, 65, 432

inheritance, 561

pure virtual function, 596, 622

example, 609

push

priority_queue, 352

queue, 352

stack, 351

push_back, 94, 108

vector, 94

back_inserter, 399

sequential container, 318

push_front

front_inserter, 406

sequential container, 318

put_Msg_in_Folder, 489

Q

Query, 610

& (bitwise AND), 610

definition, 614

~ (bitwise NOT), 610

definition, 614

| (bitwise OR), 610

definition, 614

<< (output operator), 615

definition, 613

design, 609–611

interface, 610

operations, 607

Query_base, 609

definition, 612

member functions, 609

queue

<< (output operator), 659

assign, 662

copy_elems member, 652, 662

definition, 648

design, 647

destroy member, 651

final class definition, 664

interface, 627

member template declarations, 661

operations, 627

pop member, 651

push, specialized, 677

push member, 652

template version, char*, 675

queue, 348, 354

constructors, 349

relational operator, 350

QueueItem, 648

as nested class, 787

constructor, 789

definition, 788

friendship, 658

CachedObj, 768

allocation explained, 769

R

Raccoon as virtual base, 741

RAII, see resource allocation is initialization

raise, 750

raise exception, see throw random file IO, 838

random-access iterator, 417, 425

deque, 417

string, 417

vector, 417

random_shuffle, 820

range

iterator, 314, 314–316, 354

left-inclusive, 314

range_error, 219

rbegin, container, 317, 412

rdstate, 290

recursive function, 249, 281

refactoring, 583, 622

referece, 317

reference, 58, 75

and pointer, 121

const reference, 59

initialization, 60

conversion from derived to base, 567

conversion from derived to multiple base, 734

dynamic_cast operator, example, 774

is polymorphic, 569

nonconst reference, 60

parameter, 232–237

pointer parameter, 236

return type, is lvalue, 249

return type and class object, 440

return type and local variable, 249

return value, 248

to array parameter, 240

reference count, see use count

reference data member, initialization, 455

reference to const, see const reference

reinterpret_cast, 183, 185

relational operator, 153

string, 85

associative container, 359

container, 321

container adaptor, 350

function object, 533

overloaded operator, 511, 520

consistent with equality, 520

pointer, 132

remove, 819

list, 423

remove_copy, 820

remove_copy_if, 820

remove_if, 819

list, 423

remove_Msg_from_Folder, 491

rend, container, 317, 412

replace, 400, 816

string, 342

replace_copy, 400, 815

replace_copy_if, 815

replace_if, 816

reserve

string, 336

vector, 331

reserved identifier, 47

resize, sequential container, 323

Resource, 700

resource allocation is initialization, 700–701

auto_ptr, 702

restricted word count program, 374

result, 148, 189

rethrow, 695, 750

return, container, 381

return statement, 245–251

from main, 247

implicit, 245

local variable, 247, 249

return type, 3, 29, 226, 227

const reference, 249

function, 281

function pointer, 278

linkage directive, 804

member function definition, 446

no implicit return type, 228

nonreference, 247

uses copy constructor, 478

of virtual function, 564

pointer to function, 278

reference, 248

reference yields lvalue, 249

void, 245

return value

conversion, 246

copied, 247

reverse, 819

list, 423

reverse iterator, 405, 412–415, 425

-- (decrement), 412

++ (increment), 412

base, 414

compared to iterator, 413, 414

example, 414

requires -- (decrement), 413

reverse_copy, 819

reverse_iterator, 412

container, 316

rfind, string, 346

rgcd program, 250

right manipulator, 832

right-shift (>>), 155, 190

rotate, 819

rotate_copy, 820

rule of three, 485, 503

exception for virtual destructors, 588

run time, 75

error, 38

run-time type identification, 772–780, 807

classes with virtual functions, 772

compared to virtual functions, 777

dynamic_cast, 773

example, 773

throws bad_cast, 774

to poiner, 773

to reference, 774

type-sensitive equality, 778

typeid, 775

and virtual functions, 775

example, 776

returns type_info, 776

runtime_error, 217, 219

constructor from string, 218

rvalue, 45, 75

S

safety, exception, 700

Sales_item, 21

addition (+), 23, 517

throws exception, 217, 699

class definition, 64, 258–265

compare function, 604

compound assignment (e.g.,+=), 521

conversion, 461

default constructor, 263

equality operators (==), (!=), 519

explicit constructor, 462

handle class, 599

clone function, 602

constructor, 601, 602

definition, 600

design, 599

multiset of, 605

using generic Handle, 669

header, 21, 67, 264

input (>>), 516

istream constructor, 452

no relational operators, 520

operations, 21

output (<<), 514

avg_price definition, 261

same_isbn, 24, 258

string constructor, 452

scientific manipulator, 830

scope, 54, 75

const object, 57, 69

block, 193

class, 65, 444, 473

compared to object lifetime, 254

for statement, 15

friend declaration, 466

function, 227

function template specialization, 674

global, 54, 74

local, 54, 75

multiple inheritance, 737

namespace, 713–717

statement, 194

template parameter, 629

using declaration, 720

using directive, 721

example, 722

name collisions, 723

scope (::)

base class members, 569

namespace member, 750

scope operator (::), 8, 30, 78, 108

class member, 85, 445

container defined type, 317

member function definition, 262

namespace member, 713

to override class-specific memory allocation, 765

to override name lookup, 449

Screen, 435

class template, 655

concatenating operations, 441

display, 442

do_display, 442

friends, 465

get definition, 446

get members, 436

get_cursor definition, 446

CachedObj, 768

Menu function table, 785

move members, 441

set members, 441

simplified, 781

size_type, 435

ScreenPtr, 523

arrow operator (–>), 525

dereference (*), 524

use counted, 523

ScrPtr, 523

search, 813

search_n, 813

self-assignment

auto_ptr, 705

check, 490

use counting, 498

semantics, value, 499, 503

semicolon (;), 3

semicolon (;), class definition, 440

sentinel, 97, 108

separate compilation, 67, 76

inclusion model for templates, 644

of templates, 643

separate compilation model for templates, 645, 684

sequence, escape, 74

sequence (Xnnn), hexadecimal escape, 40

sequential container, 306, 354

assign, 328

assignment (=), 328

back, 324

clear, 327

const_iterator, 316

const_reverse_iterator, 316

constructor from element count uses copy constructor, 478

uses element default constructor, 460

constructors, 307–309

deque, 306

element type constraints, 309, 323

empty, 323

erase, 326

front, 324

insert, 319

iterator, 316

list, 306

operations, 316–330

performance characteristics, 333

pop_back, 326

pop_front, 326

priority_queue, 348

push_back, 318

push_front, 318

queue, 348

rbegin, 412

rend, 412

resize, 323

returning a, 381

reverse_iterator, 316, 412

size, 323

size_type, 316

stack, 348

supports relational operators, 321

swap, 329

types defined by, 316

value_type, 317

vector, 306

set, 356, 388

as element type, 311

assignment (=), 328

begin, 372

bidirectional iterator, 417

clear, 359

constructors, 372

count, 372

element type constraints, 309

empty, 359

end, 372

equal_range, 379

erase, 359, 372

find, 372

insert, 373

iterator, 374

key type constraints, 360

lower_bound, 377

operations, 358

overriding the default comparison, 604

rbegin, 412

rend, 412

return alternatives, 381

return type from insert, 373

reverse_iterator, 412

size, 359

supports relational operators, 359

swap, 329

upper_bound, 377

value_type, 372

set_difference, 822

set_intersection, 619, 822

set_symmetric_difference, 822

set_union, 822

setfill manipulator, 832

setprecision manipulator, 829

setstate, 289, 290

setw manipulator, 832

shift operator, 155, 190

short, 34

short-circuit evaluation, 152

overloaded operator, 508

shorterString, 248

showbase manipulator, 827

showpoint manipulator, 831

signed, 35, 76

conversion to unsigned, 36, 180

size, 108

string, 83

vector, 93

associative container, 359

priority_queue, 352

queue, 352

sequential container, 323

stack, 351

size_t, 104, 108, 146

and array, 113

size_type, 84, 108

string, 84

vector, 93

container, 316

sizeof operator, 167

skipws manipulator, 833

sliced, 579, 622

SmallInt, 536, 550

conversion operator, 537

smart pointer, 495, 503, 553

handle class, 599

overloaded –> (arrow operator) and * (dereference), 524

overloaded (++) and (*), 526

sort, 401, 817

source file, 4, 29

naming convention, 264

specialization

class template

definition, 675

member defined outside class body, 676

partial, 678

partial specialization, 684

class template member, 677

declaration, 677

function template

compared to overloaded function, 673

declaration, 672, 673

example, 672

scope, 674

template, namespaces, 730

specifier, type, 48, 76

splice, list, 423

sstream

header, 285, 300

str, 301

stable_partition, 817

stable_sort, 403, 817

stack, 348, 354

constructors, 349

relational operator, 350

stack unwinding, 691, 750

standard error, 6, 29

standard input, 6, 29

standard library, 5, 29

standard output, 6, 30

state, condition, 302

statement, 2, 30

break, 212, 223

continue, 214, 223

do while, 210

for, 14, 29, 207

goto, 214, 224

if, 17, 29, 195, 224

return, 245–251

switch, 199, 224

while, 12, 30, 204, 224

compound, 193, 223

declaration, 193, 224

expression, 192, 224

labeled, 214, 224

null, 192, 224

return, local variable, 247, 249

statement block, see block

statement label, 214

statement scope, 194

static (file static), 719

static class member, 467, 474

as default argument, 471

class template, 665

accessed through an instantiation, 666

definition, 666

const data member, initialization, 470

const member function, 469

data member, 469

as constant expression, 471

inheritance, 576

member function, 467

this pointer, 469

static object, local, 255, 281

static type, 568, 622

determines name lookup, 590

multiple inheritance, 735

static type checking, 44, 76

argument, 229

function return value, 246

static_cast, 183, 185

std, 8, 30

stdexcept header, 217, 219

store, free, 135, 145

str, 301

strcat, 133

strcmp, 133

strcpy, 133

stream

istream_iterator, 407

ostream_iterator, 407

flushing buffer, 290

iterator, 405, 407–412

and class type, 410

limitations, 411

used with algorithms, 411

not flushed if program crashes, 292

type as condition, 19

stream iterator, 425

strict weak ordering, 360, 389

string, C-style, see C-style string string, 80–89

addition, 86

addition to string literal, 87

and string literal, 81, 140

append, 342

are case sensitive, 344

as sequential container, 335

assign, 340

assignment (=), 86

c_str, 140

c_str, example, 294

capacity, 336

compare, 347

compared to C-style string, 134

compound assignment, 86

concatenation, 86

constructor, 80, 338–339

default constructor, 52

empty, 83

equality (==), 85

equality operator, 347

erase, 340

find, 344

find_first_not_of, 346

find_first_of, 345

find_last_not_of, 346

find_last_of, 346

getline, 82

getline, example, 300

header, 80

input operation as condition, 82

input operator, 81

insert, 340

output operator, 81

random-access iterator, 417

relational operator, 85, 347

replace, 342

reserve, 336

rfind, 346

size, 83

size_type, 84

subscript operator, 87

substr, 342

string literal, 9, 30, 40

addition to string, 87

and string library type, 81, 140

and C-style string, 140

concatenation, 41

stringstream, 285, 299–301, 302

see also istream

see also ostream

str, 301

strlen, 133

strncat, 133

strncpy, 133

struct,see also class

default access label, 433

default inheritance access label, 574

struct, keyword, 66, 76, 474

in variable definition, 440

structure, data, 20, 28

Studio, Visual, 4

subscript ([ ]), 87, 108, 146, 389

bitset, 105

deque, 325

map, 363

string, 87

vector, 94, 325

and multi-dimensioned array, 142

and pointer, 124

array, 113

overloaded operator, 522

reference return, 522

valid subscript range, 88

yields lvalue, 88

subscript range

string, 88

vector, 96

array, 114

substr, string, 342

subtraction (-), 150

iterator, 101, 313

pointer, 123

swap, 329, 816

container, 329

swap program, 233, 245

swap_ranges, 816

switch statement, 199, 224

default label, 203

and break, 201–203

case label, 201

compared to if, 199

execution flow, 201

expression, 203

variable definition, 204

synthesized assignment (=), 483, 503

multiple inheritance, 737

pointer members, 493

synthesized copy constructor, 479, 503

multiple inheritance, 737

pointer members, 493

virtual base class, 747

synthesized copy control, volatile, 800

synthesized default constructor, 264, 281, 459, 474

inheritance, 581

synthesized destructor, 485, 486

multiple inheritance, 737

pointer members, 493

(tab character), 40

table of library name and header, 810

template

see also class template

see also function template

see also instantiation

class, 90, 107

class member, see member template

link time errors, 635

overview, 624

template keyword, 625

template argument, 625, 684

and function argument type checking, 638

class template, 628

conversion, 638

deduction, 684

from function pointer, 640

deduction for class template member function, 653

deduction for function template, 637

explicit and class template, 636

explicit and function template, 642

and function pointer, 643

specifying, 642

pointer, 671

template argument deduction, 637

template class, see class template

template function, see function template

template parameter, 625, 628–633, 684

and member templates, 663

name, 628

restrictions on use, 629

nontype parameter, 625, 628, 632, 684

class template, 655

must be constant expression, 633

scope, 629

type parameter, 625, 628, 630, 684

uses of inside class definition, 649

template parameter list, 625, 684

template specialization, 672, 684

class member declaration, 677

compared to overloaded function, 673

definition, 675

example, 672

function declaration, 672, 673

member defined outside class body, 676

member of class template, 677

parameter matching, 673

partial specialization, 678, 684

scope, 674

template<>, see template specialization

temporary object, 247

terminate, 219, 219, 224, 692, 750

TextQuery

class definition, 382

main program using, 383

program design, 380

program interface, 381

revisited, 609

this pointer

implicit parameter, 260, 281, 431, 440

in overloaded operator, 483, 508

static member functions, 469

three, rule of, 485, 503

throw, 216, 216, 224, 689, 750

example, 217, 290

execution flow, 218, 691

pointer to local object, 690

rethrow, 695

tolower, 88

top

priority_queue, 352

stack, 351

toupper, 88

transform, 815

transformation program, word, 370

translation unit, see source file trunc (file mode), 296

try block, 216, 217, 224, 750

try keyword, 217

type

abstract data, 78, 473

arithmetic, 34, 73

built-in, 3, 28, 34–37

class, 20, 28, 65

compound, 58, 73, 145

dynamic, 568, 622

function return, 281

incomplete, 438, 474

integral, 34, 75

library, 29

nested, see nsted class786

return, 3, 29, 226, 227

static, 568, 622

determines name lookup, 590

name lookup and multiple inheritance, 735

type checking, 44

argument, 229

with class type conversion, 541

ellipsis parameter, 244

name lookup, 269

reference to array argument, 240

type identification, run-time, 772–780, 807

type specifier, 48, 76

type template parameter, 628, 630, 684

see also template parameter type_info, 807

header, 219

name member, 780

no copy or assign, 780

operations, 779

returned from typeid, 776

typedef

and pointer, 129

and pointer to member, 783

pointer to function, 276

typedef, 61, 76

typeid operator, 775, 807

and virtual functions, 775

example, 776

returns type_info, 776

typename, keyword

compared to class, 631

in template parameter, 630

inside template definition, 632

U

U_Ptr, 496

unary function object, 533

unary minus (-), 150

unary operator, 148, 189

unary plus (+), 150

uncaught exception, 692

undefined behavior, 41, 76

dangling pointer, 176

synthesized copy control, 494

invalidated iterator, 315

uninitialized class data member, 459

uninitialized pointer, 117

uninitialized variable, 51

underflow_error, 219

unexpected, 708, 750

uninitialized, 8, 30, 51, 76

uninitialized pointer, 117

uninitialized_copy, 755, 759

uninitialized_fill, 755

union, 792, 807

anonymous, 795, 805

as nested type, 794

example, 794

limitations on, 793

union keyword, 793

unique, 402, 819

list, 423

unique_copy, 412, 820

unitbuf, manipulator flushes the buffer, 291

unnamed namespace, 718, 750

local to file, 718

replace file static, 719

unsigned, 35, 76

conversion to signed, 36, 180

literal (numU or numu), 39

unsigned char, 36

unwinding, stack, 691, 750

upper_bound, 814

associative container, 377

book finding program, 378

example, 607

uppercase manipulator, 828

use count, 495, 503

design overview, 495

generic class, 667

held in companion class, 496

pointer to, 600

self-assignment check, 498

user, 433, 563

using declaration, 78, 108, 720, 750

access control, 573

class member access, 574

in header, 80

overloaded function, 728

overloaded inherited functions, 593

scope, 720

using directive, 721, 751

overloaded function, 729

pitfalls, 724

scope, 721

example, 722

name collisions, 723

utility header, 356

V

value initialization, 92, 108

map subscript operator, 363

vector, 92

and dynamically allocated array, 136

deque, 309

list, 309

of dynamically allocated object, 175

and resize, 324

sequential container, 309

vector, 309

value semantics, 499, 503

value_type, 389

map, multimap, 361

sequential container, 317

set, multiset, 372

varargs, 244

variable, 8, 30, 43–55

define before use, 44

defined after case label, 204

definition, 48

definitions and goto, 215

initialization, 48, 50, 76

constructor, 452

local, 227, 281

scope, 55

vector, 757

capacity, 757

memory allocation strategy, 757

push_back, 758

reallocate, 758

size, 757

using operator new and delete, 761

using explicit destructor call, 763

using placement new, 762

Vector, 90–95, 354

argument, 237

as element type, 311

assign, 328

assignment (=), 328

at, 325

back, 324

begin, 97, 317

capacity, 331

clear, 327

const_iterator, 99, 316

const_reference, 317

const_reverse_iterator, 316

constructor from element count, uses

copy constructor, 478

constructor taking iterators, 140

constructors, 91–92, 307–309

difference_type, 316

element type constraints, 309, 323

empty, 93, 323

end, 97, 317

erase, 326, 402

invalidates iterator, 326

front, 324

header, 90

initialization from pointer, 140

insert, 319

invalidates iterator, 320

iterator, 97, 316

iterator supports arithmetic, 312

memory allocation strategy, 756

memory management strategy, 330

parameter, 237

performance characteristics, 334

pop_back, 326

push_back, 94, 318

invalidates iterator, 321

random-access iterator, 417

rbegin, 317, 412

reference, 317

relational operators, 321

rend, 317, 412

reserve, 331

resize, 323

reverse_iterator, 316, 412

size, 93, 323

size_type, 93, 316

subscript ([ ]), 325

subscript operator, 94

supports relational operators, 313

swap, 329

type, 91

types defined by, 316

value_type, 317

vector capacity program, 331

viable function, 270, 282

with class type conversion, 545

virtual base class, 741, 751

ambiguities, 743

conversion, 743

defining base as, 742

derived class constructor, 744

name lookup, 743

order of construction, 746

stream types, 741

virtual function, 559, 566–570, 622

assignment operator, 588

calls resolved at run time, 568

compared to run-time type identification, 777

default argument, 570

derived classes, 564

destructor, 587

multiple inheritance, 736

exception specifications, 710

in constructors, 589

in destructor, 589

introduction, 561

multiple inheritance, 735

no virtual constructor, 588

overloaded, 593

overloaded operator, 615

overriding run-time binding, 570

pure, 596, 622

example, 609

return type, 564

run-time type identification, 772

scope, 594

static, 469

to copy unknown type, 602

type-sensitive equality, 778

virtual inheritance, 741, 751

virtual keyword, 559

Visual Studio, 4

void, 34, 76

return type, 245

void*, 119, 146

const void*, 127, 145

volatile, 800, 807

pointer, 800

synthesized copy control, 800

vowel counting program, 200

W

wcerr, 286

wchar_t, 34

literal, 40

wchar_t streams, 286

wcin, 286

wcout, 286

weak ordering, strict, 360, 389

wfstream, 286

what, see exception while statement, 12, 30, 204, 224

condition in, 205

whitespace, 81

wide character streams, 286

wifstream, 286

window, console, 6

Window_Mgr, 465

wiostream, 286

wistream, 286

wistringstream, 286

wofstream, 286

word, 35, 76

word count program, 363

restricted, 374

word per line processing

istringstream, 370, 386

istringstream, 300

word transformation program, 370

WordQuery, 609

definition, 616

wostream, 286

wostringstream, 286

wrap around, 38

wstringstream, 286

X

Xnnn (hexadecimal escape sequence), 40

Z

ZooAnimal, using virtual inheritance, 741

ZooAnimal class hierarchy, 731

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

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