scale
function, 404–409
Scientific notation, 61–62
Scope, 137, 220–221, 226–227
block, 137, 226–227
global, 226–227
local, 220–221, 226–227
variables, 220–221, 226–227
Scope resolution operator (::
), 559–560
Searching arrays, 416–418
Searching linked lists, 753–756
Secondary (auxiliary) memory, 3, 6–7
Selection sort, 419–420
Semantics, 45
Semicolons (;
), 24, 146, 149–150, 549
Sentinel value, loop design and, 158
Sequential access, memory and, 6
Sequential containers, 976–981
set
algorithms, 1005
set
class, 985–992
setf
function, 327–329
setprecision
manipulator, 331
setw
manipulator, 331
Shallow copy, objects, 571–572
short
data type, 63
Short-circuit evaluation, 115
Single quotes (‘ ’) for constant characters, 65
Single-precision numbers, 61
Size (number of elements), 381–384, 396, 413–416, 428–429, 495–496, 670–673
array parameters, 396
arrays, 381–384, 396, 413–416, 428–429
capacity compared to, 494
constructors and, 670–673
declared, 381
dynamic arrays, 670–673
function arguments and, 416
multidimensional arrays, 428–429
partially filled arrays, 413–415
resize
function, 496
vectors, 495–496
Smart pointers, 1019–1025
Software, 2, 7–8, 17, 717
abstract data types (ADT), 717
computer operating systems, 7–8
life cycle, 17
programs, 2
reusable components, 717
Sorting algorithms, 1006
Sorting arrays, 419–425
Source code, 9
Spacing, 24, 26, 202, 340–341
C++ programming, 24
character I/O and, 340–341
function definition and, 202
sqrt
function, 183–185, 187
Square brackets [ ]
, 380–381, 394–395, 429, 433, 494
srand
function, 187, 189
Stack
class, 768–772, 981–985
Stacks, 767–768, 802–804, 803–804
empty, 772
implementation of, 770–772
last-in/first-out (LIFO) data structure, 768
linked lists as, 767–768
overflow, 804
pointers and, 767–768
pop
function, 772
recursion and, 802–804
Standard Template Library (STL), 959–1034. See also Templates
Statements, 21–26, 33
C++ programming instructions, 21–26, 33
cin
(input), 21–23
cout
(output), 21–23
direction arrows (<< >>)
, 21
directives #
, 25
executable, 21–26
#include
directive, 21, 25, 26
new line (\n
), 23
return
, 25–26
semicolon (;
), 24
Static variables, 520
static_cast<double>
, 190–192
std::array
, 1007–1008
std namespace, 337–338
Stepwise refinement, 182–183
Storage, memory as, 6
strcat
function, 461–462
strcmp
function, 459–462
strcpy
function, 459–463
Streams, 50, 307–378
appending to a file, 322–324
arguments to functions, as, 334
character I/O and, 340–362
cin
as, 309
classes and, 314–317
cout
as, 309
declaring, 310–312
default arguments, 350–351
fail
function, 316
file names and, 310–312, 320
files and, 308–340
flags and, 327–329
formatting functions, 325–330
ifstream
, 310–311, 320
input/output (I/O), 50
in_stream
, 309, 310–311, 314–316, 320
manipulator functions for, 331
member functions and, 314–316, 340–351
namespaces and, 337–338
objects and, 314–317
ofstream
, 310–311, 320
output, formatting using, 325–340
out_stream
, 309, 310–312, 314–316, 320, 327–328
parameters, 348–351
using directives and, 337–338
variables as, 310
string
class, 66–68, 474–490
<string>
library, 474, 476
characters, 66–68
comparison operators and, 484, 489
concatenation (+), 66–67, 474
constants converted to, 475
data types and, 66–68
default constructor for, 475–476
double quotes (” ”) for characters, 64–65
getline
function, 477–478, 480–481
input/output (I/O) using, 477–479
lexicographic ordering of, 484
member functions, 482–485
object-to-C string conversion, 489–490
palindrome testing program example, 486–489
variable declaration, 66–68
whitespace characters and, 68
String functions, 1043
String values, 458–460, 670–673
C strings, 458–460
dynamic arrays, 670–673
implementation, 673–675
size of, 670
String variables, 324–325
stringvar
class, 670–673
strlen
function, 461
strncat
function, 461
strncmp
function, 461
strncpy
function, 459, 461
Structures, 544–552, 577, 742–744
braces { }
for, 545, 549
classes compared to, 544–552, 577
diverse data of, 544–549
dot operator (.
) for, 547, 552
functional arguments, as, 550–551
hierarchy of, 551
initializing, 553
linked lists and, 742–744
member names, 545, 547–548
member values, 545, 548
member variables, 545, 547–549, 552
nodes as, 742–744
pointer variables for, 743–744
semicolons (;
) for, 549
value, 545
Stubs, function testing using, 284–286
Subexpressions, 115
Subtasks, 251–303
assert
macro, 290–291
call-by-reference parameters, 259–266
debugging functions, 282–287
functions for, 251–303
procedural abstraction, 273–281
testing functions, 282–287
void
functions, 252–259
Subtraction operator (-
), 70
switch statements, 128–135
break
statements, 131–133
menus, 133–134
multiway branching, 128–135
Syntax, 30, 46, 941–943
class templates for, 941–943
errors, 30
variable declaration and, 45