Index

Symbols

#, 26

#include preprocessor, 26

%, 46

() parentheses, 51, 59, 157

*/ ( star-slash comments), 22, 26

/* (slash-star comments), 22, 26

// (double slash comments), 22, 26

* (asterisk), 171

* (dereference operator), 142

+ operator, 223

++ (plus-plus), 47

–– (minus-minus), 47

. (dot operator), 114

80/80 rule, PostMaster, 358-359

= (assignment operator), 35

== (equality operator), 52, 225

>passing by references, 185

A

abstract data types, 273-276

hierarchies, 280-284

virtual functions, 276-277

implementing, 277-280

abstraction, hierarchies, 280-284

abstracts, types, 284

access in code, 405

accessing

class members, 114

data members with pointers, 157-158

members of contained class, 312

accessors, 115

add() function, 25

adding

classes, simulating alarm systems, 348

variables in C++, 49

addition operator, overloading, 220-222

Addresser.cpp, 138

addresses, 143

of operators on references, 171-173

pointers, 144-146

storing in pointers, 140-142

ADT (abstract data types), virtual functions, 276

advanced for loops, 88

Alabama Crimson Tide, 407

alarm systems, simulating, 344

adding more classes, 348

anaylsis and requirements, 345

conceptualization, 345

designing classes, 347-348

event loops, 348-350

high-level and low-level design, 346

analysis, simulating alarm systems, 345

AND operator, 56

Animal.cpp, 280-283

APIs (application programming interfaces), 359

PostMaster, 359-361

Area.cpp, 65, 73

AreaCube program, 73

arguments, 23

functions, 24-25

passing to base constructors, 241-245

ArrayFunction.cpp, 317-319

arrays, 97-99

accessing, 99

character, 104-106

initializing, 100

multidimensional, 101-102

initializing, 102-103

memory, 103

of pointers to functions, 317-319

peaks, 97

writing past the end of, 99

assigning values to variables, 35-36

assignment operator, 35, 229

assignment operators, 46

Assignment.cpp, 172, 224-225

asterisk (*), 171

auto keyword, 337

auto-typed variables, C++, 335-337

average(), 75

avoiding memory leaks, 150-151

B

bad luck, number 13, 108

Badger program, 85

Badger.cpp, 85

BadTeacher.cpp, 91

base 2, 412

base 10, 410-412

base class method, hiding, 247-249

base constructors, passing arguments to, 241-245

base methods, calling, 249-250

Big Ten, 387

binary numbers, 409, 413-414

base 2, 412

bits, 413

black boxes, color of, 93

Box.cpp, 102

BoxMaker.cpp, 89

braces, code, 401-402

breaking out of loops, 83-84

BridgeKeeper.cpp, 105

bugs, 389-390

bulletproof programs, 390

Bushnel, R. G., 285

bytes, 413

C

C++, 5-6, 331

auto-typed variables, 335-337

compile-time constant expressions, 333-335

errors, 333

for loop, 338

null pointer constants, 332-333

reasons for using, 15-16

styles of programming, 16-18

C++-style comment, 22. See also double slash (//) comment

C++0X, 331, 338

C-style comments, 22. See also slash-star (/*) comments

Calculator, 25

Calculator.cpp, 24

calling base methods, 249-250

camel case, 404

capitalization in code, 404

carboxylic acid with potassium ions, 369

case-sensitivity, variable names, 35

catch statements, 396

catching exceptions, 395-396

by reference and polymorphism, 397-400

caught exceptions, 391

character arrays, 104-106

Circle.cpp, 334-335

class constructors, writing, 211

class declarations, organizing, 126

class definitions in code, 406

class keyword, 113

class members, accessing, 114

class polymorphism, 19

Classe, A., 285

classes, 112, 134

adding simulating alarm systems, 348

containment of, 307-312

accessing members, 312

copying by value versus reference, 313

filtering members, 312-313

declaring, 113

designing

PostMaster, 353-354

simulating alarm systems, 347-348

friends, 313-314

objects, defining, 114

with other classes as member data, 129, 132-133

private versus protected, 236-238

clown collete, 197

code

program text guidelines, 403

spelling/capitalization, 404

writing professional-quality code, 400-401

access, 405

braces, 401-402

class definitions, 406

comments, 404-405

const, 406

identifier names, 403-404

include files, 406

long lines, 402

program text, 403

spelling and capitalization of names, 404

switch statements, 402

code listings

driver programs, 367

polymorphic exceptions, 400

Combat.cpp, 336-337

combining operators, 47

comments, 22-23

C++-style, 22

C-style, 22

double slash (//), 22, 26

in code, 404-405

slash-star (/*), 22, 26

star-slash (*/), 22, 26

compile-time constant expressions, 333-335

compiler and linker, 6

compilers, 16

constructors, 120-122

finding, 6-9

compiling, 16

source code, 9-10

components of linked lists, 291-299

compound if statements, 54-56

compound statements, 44

computer memory, 137

conceptualization, simulating alarm systems, 345

const

in code, 406

member functions, 125-126

reasons for using, 165

const member functions, 163-164

const pointers, 162-164

passing, 188-190

constant expressions, 334

Constantinople, 251

constants, 37-38

defining, 38

enumerated constants, 38-39

symbolic, 40

constexpr keyword, 335

ConstPasser.cpp, 188-190

ConstPointer.cpp, 163

constructors, 119

copy constructors, 206-210

default constructors, 119

inheritance, 238-240

passing arguments to, 241-245

provided by compilers, 120-122

virtual copy constructors, 261-264

containment of classes, 307-312

accessing members, 312

copying by value versus reference, 313

filtering members, 312-313

continue statement, 84-85

continuing to the next loop, 84-85

conversion operators, 225-227

int(), 227-228

convert() function, 67-69

copies, shallow copies, 206

copy constructor, 229

copy constructors, 206-210

copying

by value versus reference, contained class, 313

strings, 106-107

cost of virtual member functions, 264

Coulier, Dave, 230

Counter.cpp, 216

Counter2.cpp, 217

Counter3.cpp, 219-220

Counter4.cpp, 221

Counter5.cpp, 225

Counter6.cpp, 226

Counter7.cpp, 227-228

D

dangling pointers, 161-162

data, manipulating with pointers, 143-144

data members, 113

accessing with pointers, 157-158

data types, 30

abstract, 273-276

DataMember.cpp, 158

decimal math, 409

declaring

classes, 113

functions, 64-65

on the heap, 165

decrement operators, 47

DeepCopy.cpp, 207-209

default constructors, 119

default function parameters, 72-74

default values, 203-204

defining

functions, 65-66

objects, 114

delegation of responsibilities, linked lists, 291

delete keyword, 148-150

deleting objects, 118-119

from heap, 155-157

dereference operator (*), 142

dereferencing, 317

derivation

inheritance and, 234

syntax of, 235-236

designing

classes

PostMaster, 353-354

simulating alarm systems, 347-348

interfaces, PostMaster, 356-358

PostMaster, ongoing design considerations, 361-362

PostMasterMessage class, 359

destructors, 119

inheritance, 238-240

virtual destructors, 261

development cycle, 343-344

Diogenes, 301

Disney World, 183

dividing up projects, PostMaster, 352-353

do-while loops, 85-86

dot operator (.), 114

double slash (//) comments, 22, 26

doubly linked lists, 290

drawShape() function, 202

driver programs, PostMaster, 362-368

Driver.cpp, 362-368

Dusky Seaside Sparrow, 183

E

editing Path, G++, 8

elements, arrays, 97

else keyword, 53-54

Employee.cpp, 310-312

encapsulation, 112, 347

object-oriented programming, 18

enumerated constants, 38-39

equality operator (==), 225

errors, 390

arrays, 99

C++, 333

event loops, simulating alarm systems, 348-350

exception handling, 390-391

Exception.cpp, 392-395

exceptions, 148, 390-391

how they are used, 391-395

polymorphic, 400

try blocks, 395

catching exceptions, 395-396

catching exceptions by reference and polymorphism, 397-400

Expression.cpp, 45

expressions, 44-45

values, 58

F

factor(), 180

Favre, Henri, 369

Fell, Norman, 40

fence post error, 99

Fifteens program, 84

Fifteens.cpp, 84

filtering members of contained class, 312-313

findArea() function, 65-66, 74

finding compilers, 6-9

for loops, 86-88

advanced, 88

C++, 338

Fourteens program, 83

Fourteens.cpp, 83

friend classes, 313-314

friend functions, 314

arrays of pointers, 317-319

arrays of pointers to member functions, 325-326

passing pointers to, 319-322

pointers to, 314-317

pointers to member functions, 322-325

typedef with pointers to functions, 322

function arguments, 26

passing by reference, 174-176

function definitions, organizing, 126

function headers, 179

function names, 24

function overloading, 74-75

inline functions, 75-76

function parameters, 26

function pointers, 314-317

function polymorphism, 74

function prototypes, 179

functional polymorphism, 19

FunctionOne(), 188

FunctionPasser.cpp, 319-322

FunctionPointer.cpp, 315-317

functions, 21-24, 63

add(), 25

arguments, 24-25

average(), 75

convert(), 67-69

declaring, 64-65

defining, 65-66

drawShape(), 202

factor(), 180

findArea(), 65-66, 74

friends, 314

arrays of pointers, 317-319

arrays of pointers to member functions, 325-326

passing pointers to functions, 319-322

pointers, 314-317

pointers to member functions, 322-325

typedef with pointers to functions, 322

FunctionOne(), 188

FunctionTwo(), 188

getSpeed(), 125, 134

inline, 75-76

isLeapYear(), 72

main(), 25, 63

operator++(), 219

overriding inheritance, 245-247

parameters, 69-70

default, 72-74

returning values from, 70-72

setSpeed(), 125

signature, 245

sizeof(), 30

someFunc() 265

store(), 74

stubbing out, 235

swap(), 70, 176-177

TheFunction(), 194

variables

global variables, 68-69

local variables, 66-68

virtual functions, 276-277

implementing, 277-280

virtual member functions, how they work, 257-258

FunctionTwo(), 188

G

G++, 7

editing Path, 8

getSpeed() definition, 127

getSpeed() function, 125, 134

gigabytes, 413

global variables, 76

functions, 68-69

Global.cpp, 68

gnomes, 123

gnoming, 123

gold, panning for in U.S., 387

Grader.cpp, 53

Granholm, Jackson W., 27

grasshopper ice cream, 134

Griebel, Phillip, 123

H

handling the unexpected, 390-391

Hayes, Woody, 327

head nodes, 289

heap, 146-148, 152

avoiding memory leaks, 150-151

declarations on, 165

delete keyword, 148-150

member data, 158-159

new keyword, 148

objects

creating, 155

deleting, 155-157

returning references to objects, 194-196

Heap.cpp, 149

HeapAccessor.cpp, 157

HeapCreator.cpp, 156

hexadecimal numbers, 409, 414-417

hiding base class method, 247-249

hierarchies

abstract data types, 280-284

rooted versus nonrooted, 354-356

high-level design, simulating alarm systems, 346

horseradish hot, 211

I

IDE (integrated development environments), 12

identifier names, code, 403-404

identifiers, naming guidelines, 403

if statements, compound, 54-56

If-Else conditional statements, 53

compound if statements, 54-56

else clause, 53-54

implementation

inline, 127-129

member functions, 116-118

polymorphism with virtual methods, 253-257

swap() with references, 177-178

virtual functions, abstract data types, 277-280

include files, 20, 406

increment methods, writing for operator overloading, 217-218

increment operators, 47

indirection operators, 142

infinite loops, 82

inheritance, 233

animals and, 234

constructors, 238-240

derivation and, 234-236

destructors, 238-240

object-oriented programming, 18

overriding functions, 245-247

potential problems, 270

single inheritance, problems with, 269-273

initializing

arrays, 100

multidimensional arrays, 102-103

objects, 205

initializing variables, 35

inline functions, 75-76

inline implementation, 127-129

inline keyword, 127

instance variables, 113

instances, templates, 374

instantiation, objects, 374

int() operator, 227-228

integrated development environments (IDE), 12

interfaces, designing for PostMaster, 356-358

International Code of Zooilogical Nomenclature, 59

interpreters, 16

isLeapYear() function, 72

Istanbul, 251

iteration, 81

J

jostream files, 20

K

KB, 413

keywords

auto, 337

class, 113

constexpr, 335

delete, 148-150

inline, 127

new, 148

kings, 152

kludge, 26

Klugman, Jack, 40

L

late binding, 257

lawn gnomes, 123

Leak.cpp, 194

LeapYear program, 70-71

LeapYear.cpp, 70

limitations on operator overloading, 222

linked lists, 289

allocating, 296

as objects, 299-300

components, 291-299

delegation of responsibilities, 291

infinite loops, 296

singly linked, 290

LinkedList.cpp, 291-295

linking source code, 9-10

listings

Animal.cpp, 280-283

Area.cpp, 65, 73

ArrayFunction.cpp, 317-319

Assignment.cpp, 172, 224-225

Badger.cpp, 85

BadTeacher.cpp, 91

Box.cpp, 102

BoxMaker.cpp, 89

BridgeKeeper.cpp, 105

Calculator.cpp, 24

Circle.cpp, 334-335

Combat.cpp, 336-337

ConstPasser.cpp, 188-190

ConstPointer.cpp, 163

Counter.cpp, 216

Counter2.cpp, 217

Counter3.cpp, 219-220

Counter4.cpp, 221

Counter5.cpp, 225

Counter6.cpp, 226

Counter7.cpp, 227-228

DeepCopy.cpp, 207-209

Driver.cpp, 362-368

Employee.cpp, 310-312

Exception.cpp, 392-395

Expression.cpp, 45

Fifteens.cpp, 84

Fourteens.cpp, 83

FunctionPasser.cpp, 319-322

FunctionPointer.cpp, 315-317

Global.cpp, 68

Grader.cpp, 53

Heap.cpp, 149

HeapAccessor.cpp, 157

HeapCreator.cpp, 156

Leak.cpp, 194

LeapYear.cpp, 70

LinkedList.cpp, 291-295

Mammal1.cpp, 235

Mammal2.cpp, 237-238

Mammal3.cpp, 239-240

Mammal4.cpp, 241-243

Mammal5.cpp, 246

Mammal6.cpp, 247

Mammal7.cpp, 249-250

Mammal8.cpp, 254-255

Mammal9.cpp, 255-257

Mammal10.cpp, 259-260

Mammal11.cpp, 261-263

Mammal12.cpp, 269-270

Mammal13.cpp, 271-272

MemberPointer.cpp, 322-325

Motto.cpp, 10, 19

MPFunction.cpp, 325-326

MultTable.cpp, 87

NewGrader.cpp, 54

NewRectangle.cpp, 36

NewTricycle.cpp, 120

ObjectRef.cpp, 186-187

ParamList.cpp, 375-381

Pointer.cpp, 143

PointerCheck.cpp, 144

PointerSwap.cpp, 176

PolyException.cpp, 397-400

PostMasterMessage.cpp, 360-361

Rectangle.cpp, 35, 130, 201-202

Rectangle.hpp, 129

Rectangle2.cpp, 203-204

Reference.cpp, 170

Reference2.cpp, 171

ReferenceSwap.cpp, 177

RefPasser.cpp, 191-192

ReturnPointer.cpp, 179

ReturnRef.cpp, 193-194

ReturnReference.cpp, 181

Shape.cpp, 273-275

Shape2.cpp, 277-280

SimpleEvent.cpp, 348-350

Sizer.cpp, 31

StaticCat.cpp, 304

StaticFunction.cpp, 305-306

String.hpp, 307-310

StringCopier.cpp, 106

Swapper.cpp, 332-333

Temperature.cpp, 66

TemplateList.cpp, 381-386

Thirteens.cpp, 82

This.cpp, 160

Tricycle.cpp, 116-117, 128

Tricycle.hpp, 127

ValuePasser.cpp, 175

WeightGoals.cpp, 98

Years.cpp, 48

local variables, functions, 66-68

logical operators

AND, 56

NOT, 56-57

OR, 56-57

relational precedence, 57-58

long lines of code, 402

looping, 81

loops

breaking out of, 83-84

continuing to the next, 84-85

do-while loops, 85-86

for loops, 86-88

advanced, 88

C++, 338

nested loops, 89-90

while loops, 81-83

low-level design, simulating alarm systems, 346

M

machine language, 15

main() function, 23-25, 63

Mammal1.cpp, 235

Mammal2.cpp, 237-238

Mammal3.cpp, 239-240

Mammal4.cpp, 241-243

Mammal5.cpp, 246

Mammal6.cpp, 247

Mammal7.cpp, 249-250

Mammal8.cpp, 254-255

Mammal9.cpp, 255-257

Mammal10.cpp, 259-260

Mammal11.cpp, 261-263

Mammal12.cpp, 269-270

Mammal13.cpp, 271-272

manipulating data with pointers, 143-144

mathematical operators, 46

member data

classes as, 129, 132-133

heap, 158-159

member functions

arrays of pointers to, 325-326

const, 125-126, 163-164

implementing, 116-118

overloaded, 201-203

pointers to, 322-325

member variables, 113-114

private versus public access, 115

MemberPointer.cpp, 322-325

members, 112

memory, 137

heap, 146-148

avoiding memory leaks, 150-151

delete keyword, 148-150

new keyword, 148

heap. See heap

multidimensional arrays, 103

stack, 146-148

avoiding memory leaks, 150-151

delete keyword, 148-150

new keyword, 148

storing variables in, 30-31

memory leaks, avoiding, 150-151

message format, PostMaster, 353

methods

base class method, hiding, 247-249

base method, calling, 249-250

virtual methods, implementing polymorphism, 253-257

MinGW, 7

mistakes, 390

modulus operator, 46

Morissette, Alanis, 229

Motto.cpp, 10, 19

source code, 21-22

MPFunction.cpp, 325-326

multidimensional arrays, 101-102

initializing, 102-103

memory, 103

MultTable program, 87

MultTable.cpp, 87

N

naming animals, 59

Nawrocki, Tom, 40

negative numbers, 59

nested loops, 89-90

new keyword, 148

NewGrader program, 55

NewGrader.cpp, 54

NewRectangle.cpp, 36

NewTricycle.cpp, 120

No. 1 pencils, 77

nodes, 289

inserting, 297

non-pointers, 141

non-rooted hierarchies versus rooted hierarchies, 354-356

NOT operator, 56-57

NULL, 159

null pointer constants, 332-333

null pointers, 148, 174

null references, 174

numbers

base 10, 410-412

base 2, 412

binary numbers, 412-414

base 2, 412

bits, 413

bytes, 413

gigabytes, 413

hexadecimal numbers, 414-417

KB, 413

nybbles, 413

nybbles, 413

O

object code, 16

object-oriented programming (OOP), 18, 122

encapsulation, 18

inheritance and reuse, 18

polymorphism, 19

ObjectRef.cpp, 186-187

objects

creating, 118-119

creating on heap, 155

defining, 114

deleting, 118-119

deleting from heap, 155-157

initializing, 205

linked lists as, 299-300

on the heap, returning references to, 194-196

references, 174

returning references to, 193-194

Ohio College of Clowning Arts, 197

OOP (object-oriented programming), 18, 122

encapsulation, 18

inheritance and reuse, 18

polymorphism, 19

operator overloading, 215-217

addition operator, 220-222

limitations, 222

operator=(), 223-225

postfix operator, 219-220

writing increment methods, 217-218

operator++() member function, 219

operator=(), 223-225

operators, 45

addition operator, overloading, 220-222

assignment operators, 46

combining, 47

conversion operators, 225-227

int(), 227-228

decrement, 47

dynamic cast, 273

equality (==), 225

increment, 47

indirection operator, 142

indirection (*), 142

logical operators

AND, 56

NOT, 56-57

OR, 56-57

relational precedence, 57-58

mathematical operators, 46

pointers, 142

postfix, 48-49

overloading, 219-220

precedence, 49-51

prefix, 48-49

relational, 51-52

OR operator, 56-57

organizing class declarations and function definitions, 126

overloaded member functions, 201-203

default values, 210

overloading

functions, 74-75

inline functions, 75-76

operators. See operator overloading

versus overriding, 247

overriding

functions, inheritance, 245-247

versus overloading, 247

P-Q

parameterized List objects, declaring (templates), 374, 381

parameters, functions, 69-70

default, 72-74

ParamList.cpp, 375-381

parentheses (), 51, 59, 157

passing

arguments to base constructors, 241-245

const pointers, 188-190

function arguments by reference, 174-176

passing by references, 185-188

passing pointers to functions, 319-322

Path, editing, 8

peaks array, 97

pencils, No. 1, 77

photography, red eyes, 165

Pointer.cpp, 143

PointerCheck.cpp, 144

pointers, 137-140, 143

accessing data members, 157-158

addresses, 144-146

const, 162-164

passing, 188-190

dangling pointers, 161-162

to functions, 314-317

arrays, 317-319

indirection operators, 142

manipulating data, 143-144

to member functions, 322-325

arrays, 325-326

null, 148, 174

owner of, 196

passing to functions, 319-322

reasons for using, 146

references as alternatives, 191-192

storing addresses, 140-142

storing memory addresses, 161

stray, 161-162

swap(), 176-177

this, 160-161

typedef with pointers to functions, 322

when to use, 192

wild, 141

PointerSwap.cpp, 176

PolyException.cpp, 397-400

polymorphism

catching exceptions, 397-400

implementing with virtual methods, 253-257

object-oriented programming, 19

virtual methods, 257

postfix operators, 48-49

overloading, 219-220

PostMaster, 351

80/80 rule, 358-359

APIs, 359-361

design considerations, 361-362

designing

interfaces, 356-358

PostMasterMessage class, 359

dividing projects up, 352-353

driver programs, 362-368

initial class design, 353-354

message format, 353

programming in large groups, 361

prototypes, building, 358

rooted hierarchies versus non-rooted, 354-356

PostMaster Professional, 351

PostMasterMessage class, designing, 359

PostMasterMessage.cpp, 360-361

precedence, operators, 49-51

prefix operators, 48-49

preprocessor directives, 20-21

private versus protected, 236-238

private access versus public access, 115-116

problem space, 346

problems with single inheritance, 269-273

professional-quality code, writing

access, 405

braces, 401-402

class definitions, 406

comments, 404-405

const, 406

identifier names, 403-404

include files, 406

long lines, 402

program text, 403

spelling and capitalization of names, 404

switch statements, 402

program text, code, 403

programming large groups, PostMaster, 361

programming languages, machine language, 15

programming styles, 16-18

programs

build/buy question, 356

creating, 10-11

high-level, 346

protected versus private, 236-238

prototypes, building for PostMaster, 358

public access versus private access, 115-116

R

Rectangle.cpp, 35, 130, 201-202

Rectangle.hpp, 129

Rectangle2.cpp, 203-204

red eyes in photographs, 165

Reference.cpp, 170

Reference2.cpp, 171

references, 169

address of operators, 171-173

as alternatives to pointers, 191-192

catching exceptions, 397-400

creating, 170-171

determining what can be referenced, 173-174

implementing swap(), 177-178

null references, 174

passing by, 185-188

passing function arguments, 174-176

returning multiple values, 179-181

returning to objects, 193-194

returning to objects on the heap, 194-196

returning values, 181-182

when to use, 192

ReferenceSwap.cpp, 177

RefPasser.cpp, 191-192

relational operators, 51-52

relational precedence, 57-58

requirements, simulating alarm systems, 345

responsibilities, delegation of (linked lists), 291

return statements, 24

returning

references to objects, 193-194

references to objects on the heap, 194-196

values by reference, 181-182

returning values from functions, 70-72

ReturnPointer program, 181

ReturnPointer.cpp, 179

ReturnRef.cpp, 193-194

ReturnReference.cpp, 181

returnType, 217

reuse, object-oriented programming, 18

rooted hierarchies versus non-rooted hierarchies, 354-356

Rudolph the Red-Nosed Reindeer, 265

runtime binding, 257

S

semicolon, 44

setSpeed() function, 125

shallow copies, 206

Shape.cpp, 273-275

Shape2.cpp, 277-280

signatures, 24

functions, 245

signed short integers, 33

signed variables, 32

Silbo Gomero, 285

SimpleEvent.cpp, 348-350

simulations, 344

simulating alarm systems, 344

adding more classes, 348

analysis and requirements, 345

conceptualization, 345

designing classes, 347-348

event loops, 348-350

high-level and low-level design, 346

single inheritance, problems with, 269-273

singly linked lists, 290

sizeof(), 30

Sizer.cpp, 31

slash-star (/*) comments, 22, 26

slicing virtual member functions, 259-261

solution space, 346

someFunc(), 265

source code

compiling and linking, 9-10

Motto.cpp, 21-22

spelling in code, 404

stack, 146-148

avoiding memory leaks, 150-151

delete keyword, 148-150

new keyword, 148

star-slash (*/) comments, 22, 26

statements, 43

compound statements, 44

continue, 84-85

if-else, 53

compound if statements, 54-56

else clause, 53-54

switch, 90-92

whitespace, 43-44

static member data, 303-305

static member functions, 305-307

StaticCat.cpp, 304

StaticFunction.cpp, 305-306

store() function, 74

storing

addresses in pointers, 140-142

variables in memory, 30-31

stray pointers, 161-162

strcpy(), 106

String.hpp, 307-310

StringCopier.cpp, 106

strings, copying, 106-107

strncpy(), 106

Stroustrop, Bjarne, 5, 338

Strupper, Everett, 407

stubbing out, 235

styles of programming, 16-18

swap() function, 70

implementing with references, 177-178

swap() pointers, 176-177

Swapper.cpp, 332-333

switch statements, 90-92, 402

switch-case conditional, 93

symbolic constants, 40

T

tail nodes, 289

Temperature.cpp, 66

template items, 381-386

TemplateList.cpp, 381-386

templates, 373-374

defined, 374-381

instances, 374

passing, 386

text editors, 12

TheFunction(), 194

Thirteens program, 82

Thirteens.cpp, 82

this pointer, 160-161

creating, 161

This.cpp, 160

thrown exceptions, 391

Tricycle.cpp, 116-117, 128

Tricycle.hpp, 127

try blocks, 392, 395

catching exceptions, 395-396

by reference and polymorphism, 397-400

throwing, 391

type definitions, 36-37

typedef, 36-37

pointers to functions, 322

types, 111

creating new, 112

U

UML (Unified Modeling Language), 345

unsigned short integers, 33

unsigned variables, 32

use cases, 345

V

v-pointers, 258

ValuePasser.cpp, 175

values

assigning to variables, 35-36

default values, 203-204

expressions, 58

returning by reference, 181-182

returning from functions, 70-72

returning multiple values, references, 179-181

variable types, 32-33

variables, 29, 143

adding to C++, 49

assigning values to, 35-36

auto-typed variables, 335-337

classes, 113

defining, 33-35

global, 76

functions, 68-69

local variables, functions, 66-68

signed, 32

storing in memory, 30-31

unsigned, 32

variable types, 32-33

virtual copy constructors, virtual member functions, 261-264

virtual destructors, virtual member functions, 261

virtual functions, 276-277

implementing, 277-280

virtual member functions, 258

cost of, 264

how they work, 257-258

slicing, 259-261

virtual copy constructors, 261-264

virtual destructors, 261

virtual methods, implementing polymorphism, 253-257

virtual table pointers, 258

vptr (virtual table pointers), 258

W-X

warning messages, 12

Washington, George, 152

waterfall technique, 343

WeightGoals.cpp, 98

while loops, 81-83

whitespace, 43-44, 59

wild pointers, 140, 332

word processors, 12

writing

class constructors, 211

increment methods, operator overloading, 217-218

past the end of arrays, 99

professional-quality code, 400-401

access, 405

braces, 401-402

class definitions, 406

comments, 404-405

const, 406

identifier names, 403-404

include files, 406

long lines, 402

program text, 403

spelling and capitalization, 404

switch statements, 402

Y-Z

Years.cpp, 48

“You Oughta Know,” 229

How can we make this index more useful? Email us at [email protected]

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

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