< Previous | Contents | Next >

R

rand()function, 6970 random numbers, generating,

6872

calculating number within range, 7172

Die Roller program, 6869

rand()function, 6970

seeding, 7071

random_shuffle() algorithm, 134135, 143

random-element access, 147

rank m_Rank member, BlackJack

Card class, 359

reallocation, vector memory, 136 reassigning pointers, 229

redundant parentheses, 68 reference operator (&),

189, 217

references, 187217

versus constant pointers, 232 creating, 189190

deciding how to pass arguments, 198

defined, 217 passing

to alter arguments, 191194 constant references,

197198

Inventory Displayer pro- gram, 195196

pitfalls, 196197

versus pointers, 249

Referencing program, 187189

returning, 198203

altering object through, 202 assigning to reference, 202 assigning to variable, 202 displaying value of, 201 Inventory Referencer

program, 199200

overview, 200201

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

askNumber()function, 209


askYesNo()function, 208209

computerMove()function, 213216

creating list of functions, 205

displayBoard()function, 210211

humanMove()function, 213

humanPiece()function, 209210

instructions()function, 208

isLegal()function, 212213

main()function, 207208

opponent()function, 210

pseudocode, 204

representing data, 204205

setting up, 205207

winner()function, 211212 values

accessing, 190

altering, 190191

Referencing program, 187189

refToElement() function header, 200201, 240

relational operators, 40tbl, 44

reserve()member function, 137

restricting pointers, 243, 251

return statement, 50, 158,

184185

return type, constructor, 262 return values, function, 157158

return statement, 158 specifying return type, 157 using, 158

returning pointers, 238244

altering object through, 243244

assigning to pointer, 242 assigning to variable value

pointed to by returned pointer, 242243

Inventory Pointer program, 239240

overview, 240241

using to display value, 241242

returning references, 198203, 220 altering object through, 202 assigning, 202

assigning to reference, 202 assigning to variable, 202 displaying value of, 201 Inventory Referencer program,

199200

overview, 200201

408 Index


reusability, class, 332333 role-playing game (RPG), 72 run-time errors, 4