Practical C++ Programming

Second Edition Dezember 2002
ISBN 978-0-596-00419-4
Seiten 574
EUR38.00, SFR64.90


Weitere Informationen zu diesem Buch

Inhaltsverzeichnis | Index | Probekapitel | Kolophon | Rezensionen |
Beispiele |


Index

	
[ Numbers ], [ A ], [ B ], [ C ], [ D ], [ E ], [ F ], [ G ], [ H ], [ I ], [ J ], [ K ], [ L ], [ M ], [ N ], [ O ], [ P ], [ Q ], [ R ], [ S ], [ T ], [ U ], [ V ], [ W ], [ X ]

Symbols[ Top ]
/* */ comment markers, 24
{ } (curly braces), 53, 77
      and structures, 181
( ) (default class function) operator, 324
      overloading, 507
[ ] (index) operator, 323
( ) parentheses
      with macro parameters, 154
      and simple operators, 37
-= (decrease) operator, 71, 318
+ (addition) operator, 37, 316
& (address of) operator, 223, 316, 317
& (bitwise AND) operator, 161-163, 316
&& (logical AND) operator, 77, 320
&= (AND into) operator, 318
= (assignment) operator, 41
      for classes, 204
      versus == (equal to) operator, 85
\ (backslash)
      as escape character, 44
      in preprocessor directives, 146
~ (bitwise NOT) operator, 164, 317
| (bitwise OR) operator, 163, 316
      to merge flags, 259
>> (character-to-number) operator, 254
-> (class member) operator, 324
, (comma) operator, 324, 506
: construct, 506
? construct, 506
-- (decrement) operator, 71, 318
* (dereference) operator, 222, 317
## diagnostic tag, 97
/= (divide into) operator, 71, 318
/ (division) operator, 37, 43, 316
. (dot) operator, 354
== (equal to) operator, 77, 317
      versus = (assignment) operator, 85
^= (exclusive OR into) operator, 318
^ (exclusive OR) operator, 164, 316
- (for command-line options), 236
& (for reference variables), 67
> (greater than) operator, 77, 317
>= (greater than or equal to) operator, 77, 317
+= (increase) operator, 71, 318
++ (increment) operator, 71, 318
      x++ vs. ++x, 72
>> (input) operator, 51, 266, 315, 320
<< (left shift) operator, 165, 316
< (less than) operator, 77, 317
<= (less than or equal to) operator, 76, 317
! (logical NOT) operator, 77, 320
|| (logical OR) operator, 77, 320
%= (modulus into) operator, 71, 318
% (modulus) operator, 37, 316
* (multiplication) operator, 37, 316
*= (multiply by) operator, 71, 318
- (negative) operator, 317
!= (not equal to) operator, 77, 317
<< (number-to-character) operator, 250
|= (OR into) operator, 318
<< (output) operator, 38, 266, 315, 320
->* (pointer to member) operator, 324
+ (positive) operator, 317
# (preprocess) operator, 156
' (quotation mark), 45
" (quotation mark), 45
      with include files, 153
      for strings, 45, 59
>> (right shift) operator, 165, 316
:: (scope) operator, 372, 507
; (semicolon), 37
      with if-else statements, 78
      and preprocessor directives, 146
<<= (shift left) shortcut operator, 318
>>= (shift right) shortcut operator, 318
+ (string concatenation) operator, 49
-> (structure pointer) operator, 354
- (subtraction) operator, 316
~ (tilde) in class destructor names, 201
- (unary) operator, 316

Numbers[ Top ]
\0 character, 58, 231

A[ Top ]
abstract classes, 383, 472, 474
      stat class, 474-475
accuracy of floating-point arithmetic, 341-346
      float versus double datatypes, 343
add function (for fixed point numbers), 314
adding
      comments, 510
      element to linked list, 352
      exceptions to stack classes, 394-400
      fixed point numbers, 314
      floating-point numbers, 338
addition (+) operator, 37, 316
address of (&) operator, 223, 316, 317
      (see also pointers)
addresses, variable, 221
algorithms
      foreach, 435-436
      STL, 433-434
allocating
      arrays, 349
      memory, 499
      stacks, 376
ampersand (&), for reference variables, 67
      (see also AND operator)
AND (&) operator, binary, 161-163, 316
AND (&&) operator, logical, 77, 320
AND into (&=) operator, 318
apostrophe (see quotation mark)
argc and argv arguments, 235
arguments, command-line, 235-239
arrays, 48-49
      allocating, 349
      bounds errors, 54-57
      of characters, 50
      declarations, 48
      elements, 48
      index operator [ ], 323
      infinite, module for (example), 401-416
      initializing, 53, 57, 188
      multidimensional, 57-58, 134
      as parameters, 134-135
      passing to procedures, 230
      and pointers, 227-231
            optimizing, 307
      of structures, 188-189
      subscripts, 48
      (see also structures)
ASCII characters, 44
ASCII equivalents, 517-518
ASCII files, 254
asm (assembly) statement, 508
assembly language, 8
assert statements, 55, 394-400
assignment (=) operator, 41
      for classes, 204
      versus == (equal to) operator, 85
assignment statements, 5, 41
      placement of, 83
at member function, 50
author, comments about, 27
auto qualifier, 121
auto variable class, 69
automatic
      generation of member functions, 204
      variables, 121

B[ Top ]
\b (backspace character), 45
backslash (\)
      as escape character, 44
      in preprocessor directives, 146
backspace character (\b), 45
bad member function, 246
base classes, 371
      initializing, 377
      search order, 380
binary files, 254
      with multiple structures, 264
binary I/O, 256-257, 270
binary operations (see bits)
binary operators, 316
      + (addition), 316
      & (AND), 161-163, 316
            versus logical AND (&&), 162
      / (division), 316
      ^ (exclusive OR), 164, 316
      << (left shift), 165, 316
      % (modulus), 316
      * (multiplication), 316
      ~ (NOT), 164, 317
      | (OR), 163, 316
            to merge flags, 259
      >> (right shift), 165, 316
      - (subtraction), 316
binary search, debugging, 287
binary trees, 360-364
      nodes, 360
      recursion with, 363
bitmapped graphics, 169-174
bits, 41
      constants, 167
      defining, 167
      fields, 186-188
      flags, assigning, 166
      operations, 173
      operations on, 160-175
      setting, clearing, and testing, 166-169
bitwise operators (see binary operators)
<blank> modifier, 403
blocks, 118
      normal execution of, 395-396
      stack of, 120
      (see also local variables)
body of modules, 406
boldface in comments, 26
bool, 46
bottom-up programming, 142
bounds errors, array, 54-57
brace-counter class, 475
brackets { } (see curly braces)
branching statements, 76
      if statements, 76-79
      switch statements, 110-115
break command (debugger), 283
      (see also gdb debugger)
break statements, 81, 115
      in switch statements, 111, 113
browsers, class, 100
buckets, infinite arrays, 406-408
bytes, 41, 160

C[ Top ]
C++
      history of, 3-4
      learning to program, 6
      organization of, 4-6
      programming tools for, 99-100
      standard functions in, 5
C++ compiler
      g++, 12
      Microsoft Visual, 13
      Turbo, 13
      Unix CC, 12
%c conversion, 268
C++ file I/O, 245-249
C++ interfaces, 460-461
C language, 3
      binary I/O, 270
      and C++ language, 497-503
      compilers, 145
      conversion routines, 264, 266
      free function, 500
      handling exceptions in, 501
      malloc function, 498-499
      mixing with C++ code, 503
      programming tools for, 99-100
      prototypes, 498
      strings, 58-64
            converting C++ strings to C-style strings, 63
            versus C++ strings, 64
C++ language, 4
      compared with C language, 497-503
      mixing with C code, 503
C++ preprocessor, 145-159
      #define directive, 145-150
      #include directive, 152
calculation errors, 346
call by address, 134, 139
call by value, 127, 131, 139
      and copy constructors, 203
callbacks
      functions, 137
      troubleshooting, 464-465
calling functions, 252
calloc function, 499
<carriage return> character, 255
case labels (see switch statements)
case sensitivity, 30, 39
casts, 64
      dynamic_cast operator, 388-389
      operators, 325
      static_cast operator, 64
catch keyword, 394
catch statement, 396
cerr (console error) class variable, 245
char variable type, 65, 70
character(s), 65
      arrays of, 50
      ASCII, 44
      char_type class, 473
      constants, 44
      converting, 250-253
      data, 254
      partial specialization, 430-431
      special, 45
      treated as bits, 166-169
      trigraphs, 509
character-to-number (>>) operator, 254
character-type modules, 472
char_type class, 473
chess, data structures, 368-369
cin (console input)
      class variable, 245
      object variable, 51-53
class member (->) operator, 324
classes, 3, 4, 191-209, 348
      ( ) operator for, 324
      abstract, 383, 472
      accessing members of, 197
      assignment (=) operator for, 204
      base, 371
      base_counter, 475
      browsers for, 100
      char_type, 473
      comment_counter, 476
      constant members of, 214-215
      constructors and destructors, 199-204
      copy constructors, 202-203
      declaring, 195
      default constructors, 204
      defining, 326-335
      derived, 377
      extern storage, 402-404
      fixed point, 326
      friends of (see friend classes)
      hierarchy of, 472
      input_file, 473
      interfaces, 460-461
      keywords, 197
      line_counter, 475
      member functions, 204
      member variables, 196
      members of, 216-217
      paren_counter, 476
      and pointers, 348
      pointers to members, 507-508
      problems reading, 501
      programming style for, 206-208
      pure virtual functions, 474
      search order of, 380
      stacks, 394-400
      standard, 37
      stat, 474-475
      and structures, 500
      templates of, 424-426
      token, 473
      versus structures, 208
      virtual, 383-385
clearing bits, 166-169
clog (console log) class variable, 245
close member function, 246
close system call, 260
COBOL, 9
code
      asm (assembly) statements, 508
      callbacks, 464-465
      design goals, 448-450
      design principles, 450-451
      foreach algorithm, 435-436
      generating, 429
      interfaces, 465-467
      linked lists, 461-464
      mixing, 503
      procedures, 451-453
            interfaces, 460-461
            modules, 453-457
            objects, 457-460
      requirements, 469-470
      reviews, 277-280
            metrics, 279-280
            planning, 277-279
      testing, 449
      (see also programs; source code)
comma (,) operator, 324, 506
command-line
      arguments, 235-239
      debugging switch, 281
      wildcards, 236
commands, Makefiles, 409
      (see also functions)
comment_counter class, 476
comments, 24, 101-103, 510
      boxes, 25
      "//fall through", 113
      in headers, 25, 36
      marking variable units, 29
      styles for, 26
      value of, 6
comparing strings (see strcmp function)
compiler, 9
      C language, 145
      g++, 12, 408
      Microsoft Visual C++, 13
      templates, 428
      Turbo-C++, 13
      Unix CC, 12
compiles
      conditional, 150-152
      Makefile, 408-412, 512
concatenating
      expressions (,) operator, 324
      strcat function, 59
      strings, 49
      strncat function, 60
conditional
      breakpoints, 299
      clauses (see branching statements)
      compilation, 150-152
      statements (see : construct; ? construct; switch statements)
confessional method of debugging, 280
const directive, 185
const keyword, 68, 214
      versus #define directive, 150
const parameters, 130
      reference, 133
const variable type, 67-68
constants
      bits, 167
      call by value, 139
      character, 44
      class members as, 214-215
      declaring, 67-68, 145-150
      functions as, 213-214
      hexadecimal, 70
      modifying, 508
      naming, 30
      naming conventions, 67
      octal, 70
      pointers as, 225-226
constructors, class, 199-204
      copy, 202-203
      default, 204
      in derived classes, 385
      explicit, 205
      overloading, 201
      parameterized, 201
cont command (debugger), 283
      (see also gdb debugger)
containers
      lists, 436-437
      set, 434-436
      STL, 432-433
continue statements, 82, 115
control statements, 5
control variables, 108-110
      (see also for statements)
conversion, 250
      C-style I/O, 264, 266
      dynamic_cast operator, 388-389
      flags, 251
      integer-to-floating-point, 43
      routines for, 250-253
copy constructors, 202-203
core files, 299
cout (console out) class, 37, 245
      for debugging, 280
      temporary, 281
cout (console out) object, 39, 97
cross-references, 99
c_str() member function, 63
ctype.h include file, 364
curly braces { }, 53, 77
customizing templates, 423-424

D[ Top ]
%d conversion, 267
data
      inputting, 51-53
            numbers, 51
            strings, 52
      protecting, 195
      stacks of (see stacks)
data declarations, 4, 36
data structures, 364-367
      chess, 368-369
      doubly linked lists, 357-360
      dynamic, 348
      linked lists, 351-354
      objects, 457-460
      ordered linked lists, 354-356
      templates, 428
      trees, 360-364
datatypes, 519-520
      enum (enumerated), 215
      modifying, 325
debugging, 23, 89, 96-98, 277-281
      assert statement, 55
      binary search, 287
      confessional method of, 280
      debugger as browser, 100
      divide-and-conquer method, 280
      interactively (see interactive debugging)
      serial, 280-282
      with text editor, 282
      text editor as browser, 100-101
      using a program switch, 281
      within program code, 281
dec I/O manipulator, 252
decimal numbers, 66, 250, 517-518
declarations
      arrays, 48
      class, 195
      constants, 67-68, 150
      data, 4, 36
      file variables, 264
      fixed-point numbers, 314
      functions, 125, 128
      lists, 437-445
      maps, 437
      mutable, 508
      output files, 248-250
      pointers, 222
      qualifiers, 68
      reference variables, 67
      strings, 49
      struct keyword, 498
      structures, 179, 186
      style of, 511
      templates, 421
      types, 184
      unions, 181
      variables, 29, 40, 121
            namespaces, 122
            scope, 121
decoupling interfaces, 465-467
decrease (-=) operator, 71, 318
decrement (--) operator, 71, 318
default
      constructors, 204
      parameters, 136
      statements, in switch statements (see switch statements)
#define directive, 145-150, 512
      versus const keyword, 150
      versus typedef statement, 184
#define macro, 420
defining
      cast operators, 325
      fixed-point classes, 326-335
      generic functions, 420-422
      parameterized macros, 419-420
      variable types, 184
definition stage, 419
delete function, 498
delete operator, 324, 350-351
      using brackets [ ] with, 350
deleting derived classes, 387
dereference (*) operator, 222, 317
derived classes, 377
      constructors and destructors, 385
      deleting, 387
      hiding members functions in, 385
      search order, 380
design
      callbacks, 464-465
      code
            interfaces, 460-461
            modules, 453-457
            objects, 457-460
            procedures, 451-453
      dividing tasks into modules, 417
      file formats, 262-264
      goals, 448-450
      interfaces, 465-467
      linked lists, 461-464
      modules, 417
      principles, 450-451
      programs, 471-472, 511
      requirements, 469-470
destructors, 199-201, 204
      calling virtual functions from, 387
      in derived classes, 385
      exceptions, 399-400
      naming conventions, 201
      virtual, 387
diagnostic cout, 97
directories, creating, 89-90
disk files, I/O with, 246
divide by 0 error, 299
divide into (/=) operator, 71, 318
divide-and-conquer debugging method, 280
dividing
      floating-point numbers, 43, 339
      tasks into modules, 417
division (/) operator, 37, 43, 316
documentation, Oualline's law of, 27
do_file procedure, 476
dot (.) operator, 354
double keyword, 342
double qualifier, 66, 69
      versus float datatype, 343
double quote (see quotation mark)
double-linked lists, 357
do/while loops (see while loops)
dynamic data structures, 348
dynamic_cast operator, 388-389

E[ Top ]
%e conversion, 268
ease of use as a design goal, 448
economy as a design goal, 448
editing programs, 477
elements, array, 48
else statements, 77
#endif directive, 151, 512
endl I/O manipulator, 252
end-of-line puzzle, 255
end-of-string character, 231
end-of-string marker, 58
ends I/O manipulator, 252
enum (enumerated) datatype, 185-186, 215
equal to (==) operator, 77, 317
      versus = (assignment) operator, 85
errors
      bounds errors, array, 54-57
      calculations, 346
      eliminating from code (see debugging)
      handling within programs, 393-400
      infinite recursion, 140
      messages, 446
      null effect warning, 38
      roundoff (floating-point), 340
      runtime (see runtime errors)
      stack overflow, 120
escape character (\), 44
evaluation order, 72-74
exceptions, 393-400
      in C, 501
      destructors, 399-400
      formatting, 395
      runtime library, 400
      for stacks, 394
      throwing, 396-399
exclusive OR (^) operator, 164, 316
exclusive OR into (^=) operator, 318
executable programs, 9, 10
execution, 395-396
      Makefile, 408-412
expandability as a design goal, 449
explicit class constructors, 205
exponential notation, 43
expressions
      simple, 37-38
      testing, 504
      typeid function, 509
extended precision, 67
extern modifier, 402-404
extern variable class, 69
external number formats, 311

F[ Top ]
%f conversion, 267
\f (form-feed character), 45
"//fall through" comment, 113
fast prototyping, 92
fclose (file close) function, 265
fgetc (get character) function, 265
fgets (get string) function, 266
file formats, comments on, 27
filenames, headers, 404-405
files
      ASCII, 254
      binary, 254, 264
      changing modification date of, 411
      core, 299
      designing formats for, 262-264
      directing debugging information into, 282
      disk, 246
      headers, 152, 404-405
      identification numbers for, 263
      include (see include files)
      input_file class, 473
      integer.h, 427
      I/O with (see I/O)
      main.cpp, 427
      multiple (see modules)
      object (see object files)
      output file functions, 248-250
      program, 478-496
      source (see source files)
      square.cpp, 427
      square.h, 427
      standard unbuffered, 259
      variables for, 264
file-specific namespaces, 123
fixed point class, 326-335
fixed point numbers, 310, 314
flags
      conversion, 251
      open, 249, 259
float datatype, 66, 70, 343
float keyword, 43
float.h include file, 343
floating-point numbers, 42, 66
      arithmetic, 337-346
            accuracy of, 341-346
            guard digit, 338
            overflow and underflow, 340
            roundoff error, 340, 342
            speed of, 343
      converting to integers, 43
      dividing, 43
      versus integers, 308
floating-point precision arithmetic, 343
flush command, 300
flush I/O manipulator, 252, 257
fopen (file open) function, 264
for statements, 5, 107-110, 121
foreach algorithm, 435-436
formatting
      dividing tasks into modules, 417
      exceptions, 395
      files, 262-264
      fixed-point numbers, 311
      floating-point numbers, 337
      Makefiles, 408-412
      programs, 31-33
      requirements, 469-470
form-feed character (\f), 45
FORTRAN, 9
fputc (put character) function, 266
fputs (put string) function, 266
fractional numbers, 42
fread routine, 270
free function (C language), 498-500
free library routine, 498
friend classes, 211-213
friend directive, 212
fscanf function, 269
fstream class, 246
fstream.h file, 246
functions, 5, 125-139
      body of modules, 406
      callback, 137
      calling, 252
      calloc, 499
      as class members, 197
      code, 429
      constant, 213-214
      declaring, 128
      generic, 420-422
      getline, 248
      inline, 137, 156, 306
      K&R style, 497
      length of, 33
      longjmp, 501
      and namespaces, 129
      naming conventions, 135
      as operators, 315-324
      output files, 248-250
      overloading, 135
      parameters of, 126-139
            arrays as, 134-135
            const, 130
            reference, 130-134
      pop, 394-400
      prototypes, 128, 498
      push, 394-400
      qsort, 5
      recursive, 139-140
      return(0), 36
      setjmp, 501
      single-function programs, 36
      specialization, 423
      standard, 5
      static, 217
      templates of, 420
      trigonometry, 344
      typeid, 509
      virtual, 378-383
fwrite routine, 270

G[ Top ]
g++ compiler, 12, 408
-g (compiler option), 12
gdb debugger, 283-287
      example of using, 290-299
generality as a design goal, 449
generating templates, 420
generic functions, defining, 420-422
getline member function, 248
global namespaces, 123
global variables, 118-120, 452
goto statements, 504
      programming without, 31
graphics
      bitmapped, 169-174
      histograms, 412
greater than (>) operator, 77, 317
greater than or equal to (>=) operator, 77, 317
guard digits, 338
      (see also floating-point numbers)
guidelines
      coding, 453
      design, 451
      modules, 417

H[ Top ]
headers, 404-405
      comments in, 25, 36
      files, 152
help, online Unix, 21
hex I/O manipulator, 252
hexadecimal numbers, 45, 70, 160, 250
      ASCII, 517-518
      converting, 252
hiding member functions, 385
hierarchy, class, 472
high-level languages, 9
histogram program (hist), 412
history
      of C++, 3-4
      of programming, 8-9
hyphen (-) for command-line options, 236

I[ Top ]
IDE (integrated development environment), 10
identification of storage classes, 403
if statements, 5, 76-79
      with else statement, 77
      (see also ? construct; : construct; switch statements)
#ifdef directive, 512
ifstream
      ::bad, 246
      ::close, 246
      ::open, 246
implementing
      interfaces, 465-467
      templates, 426-429
#include directive, 152
include files, 152, 404-405
      ctype.h, 364
      dstream.h, 246
      float.h, 343
      iostream.h, 245
      local, 153
      nested, 153
      stdio.h, 264
inclusive OR operator (see OR operator)
increase (+=) operator, 71, 318
increment (++) operator, 71, 318
      x++ vs. ++x, 72
#indef directive, 151
indentation, 31, 77
      styles of, 32
      tools for, 99
index [ ] operator, 323
infinite arrays, module for (example), 401-416
infinite recursion error, 140
info command (debugger), 286
      (see also gdb debugger)
information hiding, 453
      as a design goal, 449
init function, 196
initializing
      arrays, 53, 57, 188
      base classes, 377
      fixed-point numbers, 312
      stacks, 193, 196
            automatically, 199
      strings, 61
      structures, 181
      temporary variables, 120
      variables, 53-54
inline directive, and classes, 206
inline functions, 137, 306
      versus parameterized macros, 156
input (>>) operator, 51, 266, 315, 320
input_file class, 473
inputting data, 51-53
      numbers, 51
      strings, 52
instructions, 4, 5
int (integer) keyword, 40
int number type, 70
int variable type, 65
integer.h file, 427
integers, 40, 64, 234
      converting to floating-point numbers, 43
      dividing, 43
      long int type, 65, 66
      short int type, 65, 66
      signed versus unsigned, 65
      types, 66
      unsigned, 66
      very short (char type), 66
integrated development environment (IDE), 10
interaction with modules, 454
interactive debugging, 283-287
      conditional breakpoint trick, 299
interfaces
      procedures, 452, 460-461
      troubleshooting, 465-467
internal number formats, 311
invert (~) operator (see NOT operator, binary)
I/O (input/output)
      binary, 256-257, 270
      C++ file, 245-276
      C++ file package, 245-249
      conversion routines, 250-253, 264
      with disk files, 246
      manipulators, 252
      operators
            >> (input), 320
            << (output), 320
      output file functions, 248-250
      streams module, 36
      unbuffered, 258-262
ios
      ::app flag, 249
      ::ate flag, 249
      ::binary flag, 249, 255
      ::dec flag, 251
      ::fixed flag, 251
      ::hex flag, 251
      ::in flag, 249
      ::internal flag, 251
      ::left flag, 251
      ::nocreate flag, 249
      ::noreplace flag, 249
      ::oct flag, 251
      ::out flag, 249
      ::right flag, 251
      ::scientific flag, 251
      ::showbase flag, 251
      ::showpoint flag, 251
      ::showpos flag, 251
      ::skipws flag, 251
      ::trunc flag, 249
      ::unitbuf flag, 251
      ::uppercase flag, 251
iostream
      class, 245
      ::fill, 252
      ::precision, 252
      ::setf, 250
      ::unsetf, 250
iostream.h include file, 152, 245
isalpha macro, 364
istream
      class, 245
      ::getline, 248
      ::sentry, 321
italics in comments, 26
iterators
      set containers, 435
      STL, 433

J[ Top ]
justification, 251

K[ Top ]
keyboards, trigraphs, 509
keywords
      static, 403
      struct, 498
K&R-style functions, 497

L[ Top ]
L character, for long integers, 65
labels for goto statements, 505
languages
      assembly language, 8
      C (see C language)
      C++ (see C++ language)
      COBOL, 9
      FORTRAN, 9
      high-level, 9
      low-level, 9
      machine code, 9
      machine language, 8
      PASCAL, 9
%ld conversion, 267
leaves, trees, 360
left shift (<<) operator, 165, 316
length function, 60
length member function, 50
less than (<) operator, 77, 317
less than or equal to (<=) operator, 76, 317
libraries, 5
      free, 498
      malloc, 498
      standard, 10, 37
      STL, 348, 432-434
            algorithms, 433-434
            containers, 432-433
            iterators, 433
            lists, 437-445
            maps, 437
            set container, 434-436
            troubleshooting, 445-446
            waiting list, 436-437
LIFO (last-in-first-out) order, 191
linear programs, 76
line_counter class, 475
<line-feed> character, 255
linked lists, 351-360
      double-linked, 357
      infinite arrays, 406-408
      ordered, 354
      troubleshooting, 461-464
linkers, 9
list command (debugger), 284
      (see also gdb debugger)
lists
      linked (see linked lists)
      STL, 437-445
      templates, 429
      waiting, 436-437
local include files, 153
local variables, 118-120
logical operators, 319
      && (AND), 77, 162, 320
      ! (NOT), 77, 320
      || (OR), 77, 320
      and relational operators, 77
long double qualifier, 66
long int keyword, 47
long int type, 65, 66
long qualifier, 69
longjmp function (C language), 501
looping statements, 5, 76, 79
      bit operations, 173
      and break statements, 81
      control variables in (see control variables)
      for statements, 107-110
      optimizing order of, 302, 307
      ordering, 307
      while loops, 79-83, 504
low-level languages, 9
%lu conversion, 268

M[ Top ]
machine code, 9
machine language, 8
macros
      #define, 420
      defining, 419-420
      parameterized, 154-156
      replacement, 146
magic numbers, 263
main function, 125
main.cpp file, 427
make program, 408-412
make utility, 93-96
Makefile, 93-96, 512
      for multiple files, 408-412
malloc function (C language), 498-500
man pages (Unix), 21
manipulators, I/O (see I/O, manipulators)
maps, STL, 437
markers, end-of-string, 58
member functions
      at, 50
      automatically generated, 204
      constant, 213-214
      c_str(), 63
      hiding, 385
      inline, 206
      length, 50
      naming, 372
      operators as, 324-325
      searching, 380
      static, 217
      substr, 50
member variables, 196
      access privileges to, 196
      constant, 214-215
      static, 216-217
members
      classes, 507-508
      constant objects, 508
memory
      C language, 499
      leak, 351
memset library routine, 305, 412
merging flags, 259
metrics, code reviews, 279-280
Microsoft C++ compiler, 13
mixing C and C++ code, 503
modification date, changing, 411
modification times, 409
modifying
      cast operators, 325
      constant objects, 508
      programs, 477
modules, 5, 401-418
      body of, 406
      character-type, 472
      design guidelines for, 417
      dividing task into, 417
      libraries, 5
      Makefile for, 408-412
      private versus public parts, 402
      procedures, 453-457
      token, 471
      troubleshooting, 464-465
modulus (%) operator, 37, 316
modulus into (%=) operator, 71, 318
more than (see greater than)
multidimensional arrays, 57-58
      as parameters, 134
multiple files, Makefile, 408-412
multiplication (*) operator, 37, 316
multiply by (*=) operator, 71, 318
multiplying
      floating-point numbers, 339
      versus shifting, 165
multisets, 436
mutable qualifiers, 508

N[ Top ]
\n (newline character), 44
namespaces, 122-125
      declarations, 122
      file-specific, 123
      and functions, 129
      global, 123
      nested, 123
      std, 122
      using statement, 124-125
naming
      class destructors, 201
      constants, 30, 67
      functions, 135
      member functions, 372
      preprocessor directives, 146
      variables, 28, 39, 511
negative (-) operator, 317
negatives, 69
nested include files, 153
nested namespaces, 123
new function, 498
new operator, 324, 348-349
newline character, 37
newline character (\n), 44
next command (debugger), 284
      (see also gdb debugger)
nodes, trees, 360
normal execution, applying try blocks for, 395-396
NOT (~) operator, binary, 164, 317
NOT (!) operator, logical, 77, 320
not equal to (!=) operator, 77, 317
NUL character, 58, 231
null effect warning, 38
NULL pointers, 225
numbers
      converting, 250-253
      determining parity of, with &, 163
      fixed point (see fixed point numbers)
      floating-point (see floating-point numbers)
      hexadecimal (see hexadecimal numbers)
      inputting, 51
      number of decimal places for, 66
      octal (see octal numbers)
      reading, 247
      sign of, 69
number-to-character (<<) operator, 250

O[ Top ]
%o conversion, 268
O_APPEND open flag, 259
O_BINARY open flag, 259
object files, 9, 12
object-oriented design (OOD), 3, 4
objects, 4
      constant, 508
      procedures, 457-460
O_CREAT open flag, 259
oct I/O manipulator, 252
octal character codes, 44
      ASCII, 517-518
octal numbers, 70, 250
O_EXCL open flag, 259
ofstream class, 246
      open flags, 249
ones complement operator ~ (see NOT operator, binary)
OOD (object-oriented design), 4
open flags, 249, 259
open member function, 246
open system call, 258
operation cost, 307
operators
      + (string concatenation), 49
      binary (see binary operators)
      bitwise
            ^ (exclusive OR), 164
            << (left shift), 165
            ~ (NOT)
            | (OR)
            >> (right shift), 165
      casts, 64
      comma (,), 506
      delete, 350-351
      dynamic_cast, 388-389
      functions, 315-324
      I/O (see I/O, operators)
      logical (see logical operators)
      member functions, 324-325
      new, 348-349
      overloading, 336
      pointers, 223
      precedence, 521
      relational (see relational operators)
      simple, 37
      unary (see unary operators)
      bitwise (see also binary operators)
optimizing programs, 301-309
      calculation speed, 343
      considering operation costs, 307
      considering powers of two, 303-306
      integers versus floating-point numbers, 308
      loop order, 302, 307
      pointers versus arrays, 307
options, command-line command, 236
OR (|) operator, binary, 163, 316
      to merge flags, 259
OR (^) operator, exclusive, 164
OR (||) operator, logical, 77, 320
OR into (|=) operator, 318
order of operations, 72-74
ordered linked lists, 354
ordering loops, 307
O_RDONLY open flag, 259
O_RDWR open flag, 259
ostream
      class, 245
      parameter, 320
      ::read, 256-257
      ::write, 256-257
O_TRUNC open flags, 259
Oualline's law of documentation, 27
output (<<) operator, 38, 266, 315, 320
output files, 248
output redirection, 283
overflow
      errors, 120
      floating-point, 340
overloading
      ( ) (default class function) operator, 507
      class constructors, 201
      functions, 135
      operators, 336
overriding virtual functions, 382
O_WRONLY open flag, 259

P[ Top ]
packed structures, 186-188
parameters
      in class constructors, 201
      default, 136
      function, 126-139
            arrays as, 134-135
            call by address, 139
            call by value, 127, 131, 139
            constant call by value, 139
            reference, 130-134
            void, 128
      in macros, 154-156
      macros, defining, 419-420
      types of, 138
      unused, 136
paren_counter class, 476
parentheses ( )
      with macro parameters, 154
      in simple operators, 37
parity, determining with &, 163
partial specialization, 430-431
PASCAL, 9
peer reviews, 277-280
      metrics, 279-280
      planning, 277-279
permanent variables, 120-121
placing words into trees, 364-367
planning code reviews, 277-279
pointers, 221-241, 347-370
      ->* operator, 324
      and arrays, 227-231
            optimizing, 307
      binary trees (see binary trees)
      and classes, 348
      constant, 225-226
      converting to integers, 234
      declaring, 222
      to members, 507-508
      NULL, 225
      operators, 223
      to other pointers, 223
      printing value of, 226
      and structures, 234, 348
pop function, 197, 394-400
popping stacks (removing data), 191
portability of templates, 429
positive (+) operator, 317
power series, 344
powers of two, 303-306
precedence, operator, 521
precision (decimal places) of numbers, 66
precision of floating-point arithmetic, 341-346
prefix operator (see decrement operator; increment operator)
Preliminary Users' Specification, 90
preprocess (#) operator, 156
preprocessor directives, C++, 145-159
      backslash (\) in, 146
      #define, 145-150
      #include, 152
      naming conventions, 146
      parentheses ( ) with, 511
      semicolons (;) with, 146
print command (debugger), 284
      (see also gdb command)
printf functions, 267
printing
      binary trees, 364
      debugging information, 282
      pointer values, 226
      trees, 364
private member variables, 196
private module parts, 402
procedures
      do_file, 476
      interfaces, 452
      variables, 452
programming, history of, 8-9
programs, 5, 9
      assembly language, 8
      basic structure of, 36-37
      changing control variables, 108
      chess, 368-369
      commenting, 6, 101-103, 510
      compilers, 9
      creating directories, 89-90
      debugging, 23, 89, 96-98, 277-281
            debugger as browser, 100
            switch for, 281
            text editor as browser, 100-101
      decision-making in (see branching statements)
      defining special datatypes, 184
      design goals, 448-450
      design principles, 450-451
      designing, 471-472, 511
      for different machines, 150-152
      executable, 10
      files, 478-496
      format of, 31-33
      handling errors in, 393-400
      histogram (hist), 412
      instructions, 4
      machine language, 8
      maintenance, 98
      minimizing roundoff error, 342
      optimizing, 301-309
            calculation speed, 343
      placement of assignment statements, 83
      procedures, 451-453
            interfaces, 460-461
            modules, 453-457
            objects, 457-460
      requirements, 469-470
      revising and updating, 89, 99, 477
      single-function, 36
      specifications for, 87, 90-91
      splitting into modules, 401-418
      templates, 419-431
      testing, 89, 96, 449, 477
      tools for, 99-100
      transforming from high-level languages to machine code, 9-10
      troubleshooting, 510-513
      wrapper, 10
      writing style (see design; style programming)
protecting
      data in stacks, 195
      member variables, 196
prototypes, 498
pseudocode, 91
_ptr extension (see pointers)
public
      member functions, 417
      member variables, 196
      module parts, 402
pure virtual functions, 383, 474
push function, 197, 394-400
pushing stacks (entering data), 191
put member function, 255

Q[ Top ]
qsort function, 5
qualifiers, 68
      auto, 121
      mutable, 508
quotation mark ('), 45
quotation mark ("), 45
      with include files, 153
      for strings, 45, 59

R[ Top ]
\r (return character), 45
ranges of, 519-520
read member function, 256-257
reading
      numbers, 247
      strings, 248, 266
real numbers (see floating-point numbers)
recursion, 139-140
      with binary trees, 363
      infinite, 140
redirecting output, 283
redirection, I/O, 246
reference parameters, 130-134
      const, 133
      dangling, 133-134
reference variables, 67
references in comments, 27
register qualifier, 302
register variable class, 69
reinterpret_cast, 234
relational operators, 76, 317
      == (equal to), 77, 317
      > (greater than), 77, 317
      >= (greater than or equal to), 77, 317
      < (less than), 77, 317
      <= (less than or equal to), 76, 317
      != (not equal to), 77, 317
      and logical operators, 77
reliability, 448
remainder (see modulus)
replacement macros, 146
representations, fixed-point numbers, 311
requirements, design, 469-470
reserved words, 39
resetiosflags I/O manipulator, 253
return character (\r), 45
return statement, 126-133
      (see also functions)
return(0), 36
reusability as a design goal, 449
reviews
      code, 277-280
      metrics, 279-280
      planning, 277-279
revising programs, 27, 89, 99, 477
right shift (>>) operator, 165, 316
roots, trees, 360
roundoff error (floating-point), 340, 342
routines, conversion, 250-253
rules
      coding, 453
      modules, 417
run command (debugger), 283
      (see also gdb debugger)
runtime
      errors, 299-300
      exceptions, 400

S[ Top ]
%s conversion, 268
scanf function, 269
scientific notation, 43
scope (::) operator, 372, 507
scope, variable, 118-120
search, binary, 287
searching
      binary trees, 362
      member functions, 380
      virtual functions, 380
segmentation fault (core dumped), 289
Segmentation Violation error, 299
semicolon (;), 37
      with if-else statements, 78
      and preprocessor directives, 146
sentry class function, 321
serial debugging, 280-282
set container, 434-436
setbase I/O manipulator, 253
setf member function, 250
setfill I/O manipulator, 253
setiosflags I/O manipulator, 253
setjmp function (C language), 501
setprecision I/O manipulator, 253
setting bits, 166-169
setw I/O manipulator, 253
sharing modules, 404-405
shift operators
      left (<<), 165
      left (<<=) shortcut, 318
      right (>>), 165
      right (>>=) shortcut, 318
short int type, 65, 66
short qualifier, 69
side effects, 72
signed integers, 65
signed qualifier, 69
simple variables, 4
simplicity, as a design goal, 449
sine function, power series, 523, 529
single quote (see quotation mark)
size qualifiers, 69
sorting qsort function, 5
source files (source code), 9
special characters, 44, 45
specialization, 423
specialized class templates, 426
specialized template functions, 423
specifications, program, 87, 90-91
speed of floating-point calculations, 343
splitting strings, 231-234
square.cpp file, 427
square.h file, 427
sscanf function, 269
stacks, 120, 191-197, 371
      allocating, 376
      class datatype (see classes)
      designing, 192-195
      exceptions for, 394
      initializing, 193, 196
      overflow errors, 299
      protecting data, 195
      structures versus classes, 195
      trace, 290
standard classes, 37
      cout (see cout object)
standard files
      C, 265
      unbuffered, 259
standard functions, C++, 5
standard libraries, 10, 37
standard objects, cin (console input), 51-53
Standard Template Library (STL), 348, 432-434
      algorithms, 433-434
      containers, 432-433
      iterators, 433
      lists, 437-445
      maps, 437
      set container, 434-436
      troubleshooting, 445-446
      waiting list, 436-437
stat class, 474-475
statements
      asm (assembly), 508
      assert, 394-400
      assignment (see assignment statements)
      branching (see branching statements)
      catch, 396
      control, 5
      declaration (see declaring variables)
      for, 5
      if, 5
      labeling, 505
      looping (see looping statements)
      switch, 5
      throw, 396-399
      while, 5
static
      definition of, 218
      keywords, 218, 404
      member functions, 217
      member variables, 216-217
      modifiers, 403
      variable class, 69
      variables, 120
static_cast operator, 64
statistics
      line_counter class, 475
      stat class, 474-475
std namespace, 122
stderr (standard error) file, 265
stdin (standard input) file, 265
stdio.h include file, 264
stdout (standard output) file, 265
step command (debugger), 284
      (see also gdb debugger)
STL (Standard Template Library), 348, 432-434
      algorithms, 433-434
      containers, 432-433
      iterators, 433
      lists, 437-445
      maps, 437
      set container, 434-436
      troubleshooting, 445-446
      waiting list, 436-437
storage
      class variable, 120-121
      extern storage class, 402-404
strcat (string concatenate) function, 59
strchr function, 231
strcmp (string compare) function, 59, 60, 78
strcopy (string copy) function, 59, 61-63
strcpy (string copy) function, 59
streams, 245
strings, 45, 49-51, 61
      comparing (see strcmp function)
      concatenating, 49
            strcat function, 59
            strncat function, 60
      copying (see strcpy function)
      C-style, 58-64
            converting to, 63
            versus C++ strings, 64
      declarations, 49
      end-of-string character, 231
      end-of-string markers, 58
      extracting substrings, 50
      functions for, 59
      getting length of (see length function)
      initializing, 61
      inputting, 52
      length, determining, 50
      reading, 248, 266
      splitting, 231-234
      variable-length, 59
      wide, 51
      wstring data type, 51
strlen (string length) function, 59
struct keyword, 179
      in C versus C++, 498
structure pointer (->) operator, 354
structured programming techniques, 141
structures, 4, 179-181, 348
      arrays of, 188-189
      and classes, 500
      declaring, 179
      defining variables with, 180
      infinite arrays, 406-408
      initializing, 181
      packed, 186-188
      and pointers, 234, 348
      procedures, 453-457
      stacks (see stacks)
      versus classes, 195, 208
      (see also unions)
style, programming, 23, 87-104, 510-514
      classes, 206-208
      commenting, 26
      structured programming techniques, 141
subscript, array, 48
substr member function, 50
subtracting floating-point numbers, 338
subtraction (-) operator, 37, 316
suffix operator (see decrement operator; increment operator)
switch statements, 5, 110-115, 511
      and break statements, 111, 113
switches, command-line command, 236

T[ Top ]
\t (tab character), 44
targets, Makefiles, 409
Teletype, 255
templates, 419-431
      of classes, 424-426
      customizing, 423-424
      defining parameterized macros, 419-420
      of functions, 420
      generic functions, 420-422
      implementing, 426-429
      lists, 429
      partial specialization, 430-431
      portable, 429
      specialized, 423
      STL, 432-434
            algorithms, 433-434
            containers, 432-433
            iterators, 433
            lists, 437-445
            maps, 437
            set container, 434-436
            troubleshooting, 445-446
            waiting list, 436-437
temporary variables, 120-121
testing, 458
      bits, 166-169
      expressions, 504
      programs, 89, 96, 449, 477
text
      debugging, 282
      troubleshooting, 464-465
things, 221
this keyword, 325
throwing exceptions, 396-399
tilde (~) in class destructor names, 201
token class, 473
token modules, 471
top-down programming, 141
touch command, 411
tracking braces, 475
trees, 360-364
      nodes, 360
      placing words into, 364-367
      printing, 364
      recursion with, 363
trigonometry functions, 344
trigraphs, 509
troubleshooting
      callbacks, 464-465
      debugging (see debugging)
      handling errors, 393-400
      interfaces, 465-467
      linked lists, 461-464
      modules, 464-465
      programs, 510-513
      roundoff error, 341
      STL, 445-446
      (see also errors)
try blocks, 395-396
      normal execution, 395-396
try keyword, 395
Turbo-C++ compiler, 13
typedef statements, 184
typeid function, 509
types, 70
      casting, 325
      classes, 195-209
      declaring, 184
      defining special, 184
      enum (enumerated), 185-186
      partial specialization, 430-431
      pointers, 221-241
      stacks, 191-197
      structures, 179-181
      unions, 181-184
      of variables, 39

U[ Top ]
%u conversion, 268
unary operators, 316, 317
      & (address of), 317
      * (dereference), 317
      - (negative), 317
      ~ (ones complement), 317
      + (positive), 317
unbuffered I/O, 258-262
#undef directive, 512
underflow, floating-point, 340
unequal to (!=) operator, 77, 317
unexpected exceptions, 396
unions, 181-184
units for variables, 29
Unix
      CC compiler, 12
            -D switch, 152
      online help for, 21
unpacked structures (see packed structures)
unsetf member function, 250
unsigned integers, 65, 66
unsigned qualifier, 69
unused parameters, 136
updating programs, 89, 99
upgrading programs, 23
use phase, 420
using statement, 124-125

V[ Top ]
variable-length strings, 59
variables, 28
      addresses of, 221
      automatic, 121
      characters, 65
      classes of, 69
      control (see control variables)
      conversions for numbers, 250
      declaring, 40, 121
      defining special datatypes, 184
      defining with structures, 180
      for files, 264
      float, 343
      global, 118-120
      initializing, 53-54
      integers, 64
      local, 118-120
      member (see member variables)
      modifying datatypes, 325
      namespaces, 122-125
      naming, 39, 511
      permanent versus temporary, 120-121
      pointers, 221-241
      procedures, 452
      reference, 67
      and reserved words, 39
      scope of, 118-120
      signed versus unsigned, 69
      simple, 4
      size qualifiers, 69
      static, 120
      storage class of, 120-121
      strings, 49-51
      types of, 39, 70
      (see also datatypes)
version information in data files, 263
virtual
      classes, 383-385
      destructors, 387
      functions, 378-383
            called from destructor, 387
            pure, 383, 474
            search order, 380
      keywords, 379, 387
void keyword, 128, 129
      in constructor declarations, 200
volatile keyword, 68

W[ Top ]
waiting list, 436-437
walkthrough debugging, 281
warning, null effect, 38
where command (debugger), 284
      (see also gdb debugger)
while loops, 79-83, 504
      and assignment statements, 83
      and break statements, 81
      and continue statements, 82
      versus for statements, 107
while statements, 5
whitespace, 31, 51, 251, 252
      (see also formatting programs)
wide strings, 51
wildcards, command-line, 236
wrapper programs, 10
write member function, 256-257
write system call, 260
writing programs (see programs)
ws I/O manipulator, 252
wstring data type, 51

X[ Top ]
%x conversion, 268
XOR operator, 164

	

Zurück zu Practical C++ Programming


Themen

Buchreihen

Special Interest

International Sites

O'Reilly China O'Reilly France O'Reilly USA O'Reilly Japan O'Reilly Taiwan