< Previous | Contents | Next >

S

scope resolution operator (::), 9, 125, 259, 345

scopes, 161166

hiding global variables, 169 nested, 165166, 185

Scoping program, 161163

separate, 163164

Score Rater program, 4142

version 2.0, 4647

version 3.0, 4950

seeding random number generator, 7071, 79, 134

self-documenting code, 21 semicolon (;)

if statement, 43

terminating statements, 9

separate scopes, 163164

sequential container, 138, 147 set STL container, 139 shallow copy, 310

short int type, 19tbl

short modifier, 18

signed modifier, 18 Simple Boss 2.0 program,

338339

Simple Boss program, 333335 Simple Critter program, 256257 64-element array, 103

size()member function, 92, 120

skYesNo2() function, 158

slicing, OOP, 381

software reuse, 161

sort() algorithm, 135

source code, 2

srand() function, 71, 78

stack, 147, 296, 325

stack STL container, 139 standard I/O, 5

displaying text, 89

std namespace, 1013 Game Over 2.0 program,

1011

Game Over 3.0 program, 1112

using declarations, 1213

using directive, 11, 13

standard library, 5, 35 Standard Template Library.

See STL

Static Critter program, 270271

static data members, 282 accessing, 272273 constant member function

and, 269

declaring, 272

initializing, 272

Static Critter program, 270271

static keyword

declaring static data members, 272

declaring static member function, 273

static member functions, 282

calling, 273274

declaring, 273

defining, 273

std namespace, 1013

algorithms and, 133

defined, 36

Game Over 2.0 program, 1011

Game Over 3.0 program, 1112

using declarations, 1213

using directive, 11, 13

stepwise refinement defined, 146 when to use, 148

STL (Standard Template Library), 115149

algorithms, 131135

find(), 134

High Scores program, 131133

preparing to use, 133

random_shuffle(), 134135

sort(), 135

containers, 138139

Hangman game, 141145

ending, 145 entering main loop,

143144

getting player's guess, 144145

initializing variables and constants, 143

planning, 141142

setting up, 142

iterators, 123131 accessing member

functions of vector element, 129130 changing value of vector element, 128129

declaring, 125126

erase()vector member function, 130131

Hero's Inventory 3.0

program, 123125

insert()vector member function, 130

looping through vector, 126128

overview, 115116

planning programs, 139141

pseudocode, 139140 stepwise refinement,

140141

vectors, 116122, 136138 calling member functions of

element, 121122

clear()member function, 122

STL (Standard Template Library) (continued )

declaring, 119120 element insertion and

deletion, 138

empty()member function, 122

growth, 136137

Hero's Inventory 2.0

program, 117119

indexing, 121

pop_back()member function, 122

preparing to use, 119

push_back() member function, 120

size()member function, 120

strategy games, 216

streams, 34, 182

string argument, 175

string literal, 8

string m_Name member, BlackJack GenericPlayer class, 359

string objects, 33, 38, 8996, 135

array, 9697

concatenating, 92

creating, 91

defined, 110

empty()member function, 96

erase()member function, 95

find() member function, 9495

indexing, 93

iterating through, 9394

size()member function, 92 String Tester program, 8991

String Tester program, 8991

Index 409


strings

C-style strings, 101102

overview, 8

Stroustrup, Bjarne, 1

structure, defined, 284 subclass. See derived classes

subscripting operator ([ ]), 93, 99,

121, 147

subtraction ( ) operator, 14

suit m_Suit member, BlackJack

Card class, 359

superclass, 335. See also base class Swap Pointer Version program,

234236

Swap program, 191193

switch statements, 39, 5154, 77 creating ways to branch, 54 defining variables inside, 166 Menu Chooser program, 5253

syntactic sugar, 130, 250

syntax errors, 4