C++ programming, 39–110
arithmetic operators, 69–74
assignment statements, 46–49
asterisk symbol (*
), 22
backslash (\) use, 23
braces { }
, 24–25, 82, 84–86
branching mechanisms, 75–82
cin
(input) statements, 21–23, 56–57
comments, 93–95
compilers and, 24–25
compiling, 26–28
compound statements, 82
constants, 95–97
cout
(output) statements, 21–23, 50–52
data types, 44–45, 60–74
debugging, 29–31
declaration of variables, 21–23, 44–45
direction arrows (<> >>)
, 21
directives #
, 25, 52–53
expressions, 69–74
flow of control, 74–92
increment and decrement operators, 87–91
indentation, 93
input, 21–23, 56–59
input/output (I/O), 50–59
instructions, 19–23
language, 18–19
line breaks, 24
loop mechanisms, 84–91, 98
main() function, 25
names and, 49, 95–97
object code, 26–27
output, 21–23, 50–56
programmer role, 19
regular expressions, 1008–1013
return statement, 25–26
running, 26–28
spacing, 24, 26
statements, 21–26, 40–50, 82
user role, 19
variables, 21–23, 40–50, 60–69
C++11 programming, 27, 63–64
auto, 63
constructor delegation in, 589–590
conversion between strings and numbers, 490
data values, 63–64
decltype, 64
member initialization in, 589
nullptr
in, 747
regular expressions, 1008–1013
range-based, 388–389
C strings, 455–474, 486–490
<cstring> library, 460–461
arguments, 461–462
arrays, 455–474
declaration of, 455–456
equality operators = and == used for, 458–459
extraction (<<
) operator used for, 466
functions, 459–462, 469–470
getline
function, 467–468
initializing, 456–457
input/output (I/O), 466–468
insertion (<<) operator used for, 466
null (\0
) character and, 455–456, 458
number conversions, 468–472
parameters, 462
predefined functions, 459–462, 469–470
robust input, 470, 472–473
strcat
function, 461–462
strcmp
function, 459–462
strcpy
function, 459–462
string
object conversion, 489–490
values, 458–460
variables, 455–462
Call-by-reference parameters, 259–266, 521–522
ampersand symbol (&
) for, 260–261, 263, 268, 270–271, 521–522
arguments, 265–268
call-by-value combined with, 268–271
function calls, 259–260
memory locations and, 260–261
pointers, 521–522
Call-by-value parameters, 197–198, 224–226, 268–271, 676–677
arguments for, 197–198
call-by-reference combined with, 268–271
classes and, 676–677
dynamic arrays and, 676–677
local variables as, 224–226, 270–271
Calls (invocations), 183–188, 196–198, 208–211, 259–260, 265–268, 585–586
absolute value functions, 186–187
arguments and, 183–184, 197–198, 265–268
call-by-reference parameters, 259–260
call-by-value parameters, 197–198
constructors, 585–586
functions, 183–188, 196–198, 208–211, 259–260, 265–268
header files (< >)
and, 184–186
#include
directives, 184–186
loop body as, 208
nested loops and, 208–211
predefined functions, 183–188
procedural abstraction and, 208–211
programmer-defined functions, 196–198
return
statements and, 196–197
Camelback/camelcase naming convention, 45
capacity( )
function, 495–496
catch
block, 902–903, 903–904, 910–911
catch
-block parameter, 902–904
Central processing unit (CPU), 3, 6–7
char
data type, 64–66
Characters, 64–65, 68, 340–362, 1042
blank spaces and, 340–341
data values, 64–65
default arguments, 350–351
editing text files, 357–359
eof
function for, 355–356
functions, 350–351, 1042
get
function for, 340–343
input/output (I/O), 340–351
isspace
function, 360–361
member functions, 340–356
new-line (/n), 340–362, 347–348
new_line
( ) function for, 345–347, 349–350
predefined functions, 358, 360–362
put
function for, 343–344
putback
function for, 344–345
stream parameters and, 348–349
toupper
and tolower
functions for, 360–362
values returned, 360–362
whitespace, 68, 360
Child class, 602, 836, 846
Chips, computer processors and, 6
cin
(input) statements, 21–23, 56–57
Classes, 17, 66–68, 314–317, 474–490, 543–619, 621–684, 764–767, 835–894, 906–907, 975–992
abstract data types (ADT), 590–599
adapter, 981–985
ancestor, 846
arrays and, 662–684
base, 836, 838–839, 850–852, 860
C++ programming and, 17
call-by-value parameters and, 676–677
child, 602, 836, 846
constructors for, 578–590, 663, 670–673
containers, 975–992
copy constructors for, 677–681
defining, 602–605
derived, 600–605, 836–838, 839–847, 856–858, 862–863
destructors for, 673–675
dot operator (.
) for, 559–560
dynamic arrays and, 669–684
encapsulation, 558
exceptions, 906–907
file I/O and, 314–317
friend
functions, 622–644
hierarchies, 601–602
inheritance and, 600–605, 835–894
linked lists of, 764–767
member functions of, 314–316, 556–560, 572–576, 578–590
member variables, 666–669
object-oriented programming (OOP) and, 17
objects and, 314–317, 556, 568, 571–572, 578–590
overloading operators, 645–662
parent, 602–603, 836, 846
private
members used in, 561–570
public members used in, 561–570
redefining functions, 855–858
scope resolution operator (::
) for, 559–560
streams and, 314–317
string
, 66–68, 474–490
stringvar
, 670–673
structures compared to, 544–552, 577
templates for, 975–992
close
function, 312–313, 320
Coding, 213–214, 278–280, 402–409, 795–796, 814–818
array programs, 402–409
procedural abstraction and, 213–214, 278–280
recursion programs, 795–796, 814–818
Colon (:
), 559–560, 602–603
Comma (,
) separation in declarations, 44
Comments, C++ programming and, 93–95
Compact discs (CDs), 6
Comparison operators, 77–82, 484, 489
and operator (&&) for, 78–79
equal to (==
), 78, 81–82
greater than (>), 78
greater than or equal to (=
), 78, 80
less than (>=), 78
less than or equal to (<=
), 78
not equal to (!=
), 78–79
or operator (||
) for, 78, 80
string
class and, 484, 489
string of inequalities from, 80–81
Compiler programs, 9–11, 24–32, 706–720
abstract data types (ADT) interface for, 707–717
C++ programming, 24–28, 32
compiling process, 26–28
error messages, 30–31
#ifndef
directive, 25, 26, 718–720
#include
directive, 25, 26, 718
language translation using, 9–11
line breaks, 24
linking code, 9–11
object code, 9–11, 26–27
separate compilation, 706–720
spacing, 24, 26
syntax error, 30
testing, 27–29
Complete evaluation, 116
Compound statements, 82
Computer systems, 2–12
compilers, 9–11
hardware, 2–7
input/output devices, 3
languages for, 8–11
linkers, 9–11
mainframe, 2
memory, 3–6
network, 2
operating systems, 7
personal (PC), 2
processor (CPU), 3, 6–7
programs, 2, 7–11
software, 2, 7–8
Concatenation (+), strings, 66–67
const
modifier, 96–97, 396–399, 640–644
array parameters, 396–399
C++ programming using, 96–97
friend
functions and, 640–644
inconsistent use of, 399
Constant array parameters, 397
Constant iterators, 972–973
Constant parameters, 640–644
Constants, 60–62, 65, 95–97, 119–120, 221–223, 475, 638
data types, 60–62
declared, 96
enumerated types, 119–120
friend
functions and, 638
functions and, 221–223
global named, 221–223
naming, 95–97
numbers, leading zeros in, 638
single quotes (‘ ’) for characters, 65
string
class conversion, 475
Constructors, 475–476, 494, 578–590, 663, 670–673, 677–681, 847–850, 862–863
arrays and, 663, 670–673, 677–681
calling (invoking), 585–586, 663
classes and, 578–590, 670–673, 677–681
copy, 677–681, 862–863
default, 475–476, 586–587, 663
dynamic arrays, 670–673, 677–681
inheritance and, 847–850, 862–863
initialization of objects using, 578–585
member functions as, 578–590
no arguments and, 587–588
overloaded, 580
size of arrays and, 670–673
string
class and, 475–476
vectors and, 494
Container modifying algorithms, 1003–1004
Containers, 975–992, 997–998
access running times, 997–998
adapter classes, 981–985
associative, 985–992
auto, using with, 992
deque, 978
doubly linked lists, 976
efficiency of, 992–993
initializing, 992
map
class, 985–992
priority_queue
class, 981–985
queue
class, 981–985
ranged for, using with, 992
sequential, 976–981
set
class, 985–992
singly linked lists, 976
stack
class, 981–985
templates for, 975–992
type definitions in, 981
Controlling expression, 130–132
Copy constructors, 677–681, 862–863
Count-controlled loops, 158
cout
(output) statements, 21–23, 50–52, 289–290
debugging with, 289–290
direction arrows (<> >>),
21
program output using, 21–23, 50–52
streams, as variable declaration and, 21–23