< Previous | Contents | Next >

A

abstract classes, 352–356, 380, 382

Abstract Creature program, 352–354

declaring pure virtual functions, 354–355

deriving classes from, 355–356 virtual functions and, 355

Abstract Creature program, 352–354

abstraction

encapsulation and, 160

functions, 155

access control, 337–340

Simple Boss 2.0 program, 338–339

using access modifiers when deriving classes, 340

using access modifiers with class members, 339–340

access modifiers

using when deriving classes, 340 using with class members,

339–340

access_global() function, 168 accessing

array elements, 246

data members, 259–260

global variables, 168 member functions of array

element, 100

member functions of vector element, 129–130

reference values, 190

static data members, 272–273

accessor member functions, 267– 268, 282

action statement, for loop, 82 Add() member function, 292 Add New Item dialog box,

386fig

addition (þ) operator, 14, 92

address, variable, 249

advanced classes

aggregation, 287–292 container data members,

291–292

Critter Farm program, 288–290

object data members, 290–291

friend functions creating, 295

Friend Critter program, 292–294

Game Lobby program, 315–325

Lobby class, 318–320

Lobby::AddPlayer() member function, 320–322

Lobby::Clear() member function, 322–323

Lobby::RemovePlayer()

member function, 322

main() function, 324–325

operator<<() member function, 323–324

Player class, 316–318

operator overloading, 295–296 again character, looping, 57–58 aggregation, 287–292

container data members, 291–292

Critter Farm program, 288–290

defined, 325

object data members, 290–291

AI (Artificial Intelligence), 203

399

400 Index


algorithms, 131–135, 146

defined, 116

find(), 134

High Scores program, 131–133

preparing to use, 133

random_shuffle(), 134–135

sort(), 135

allocating dynamic memory, 296–303

avoiding memory leaks, 301–303

delete operator, 300–301

Heap program, 297–299

new operator, 299–300

altering

global variables, 169

iterators, 128

object through returning pointers, 243–244

object through returning references, 202

reference values, 190–191 value of variable, 26

American Standard Code for Information Interchange (ASCII), 22, 393–396

AND (&&) operator, 61tbl, 77

announceWinner()function, Tic-Tac-Toe game, 217

ANSI (ANSI/ISO) standard, 5 argument variable, 191, 197

arguments, 70

versus parameters, 184 passing references to alter,

191–194

arithmetic operators, 13–15

adding, 14

Expensive Calculator program, 13–14

floating point division, 14–15 integer division, 14–15

modulus operator, 15

multiplying, 14

order of operations, 15 subtracting, 14

Array Passer program, 244–246 arrays, 96–106

accessing member functions of array element, 100

bounds checking, 100–101

creating, 98–99

Hero's Inventory program, 96–98

indexing, 99–100

multidimensional, 103–106

creating, 105

indexing, 105–106 Tic-Tac-Toe Board

program, 103–105

pointers and, 244–248 Array Passer program,

244–246

constant pointer, 246–247 passing and returning,

247–248

versus vectors, 117, 146–147

Artificial Intelligence (AI), 203

ASCII (American Standard Code for Information Interchange), 22, 393–396

askNumber() function

assigning default arguments to parameters, 173

Mad Lib game, 182 Tic-Tac-Toe game, 209

askText()function, Mad Lib game, 182

askYesNo1() function

Mad Lib game, 157–158 Tic-Tac-Toe game, 208–209

assembly language, 2 assigning values

to Boolean variables, 22

to character variables, 21–22 to floating point variables, 21 to integer variables, 21

assignment operator (=), 21, 44,

313–315, 346–347

assignment statement, 70

associative container, 138