|
 |
 |
To access the contents, click the chapter and section titles.
C++ in Plain English
(Publisher: IDG Books Worldwide, Inc.)
Author(s): Brian Overland
ISBN: 1558284729
Publication Date: 04/01/96
Index
- # (pound sign) in directives, 22
- ^ (caret) as bitwise exclusive OR (XOR) operator, 430
- % (percent sign) as remainder operator, 430, 475-476
- & (ampersand). See ampersand
- + (plus sign). See plus sign
- : (colon). See colon
- ; (semicolon). See semicolon
- << and >> (double angle brackets). See angle brackets
- = (equal sign). See equal sign
- (->) as pointer operator, 115
- ?: (question mark colon) as conditional operator, 430
- \ (backslash), as escape sequence character, 27
- ~ (tilde). See tilde
- @ (at sign) with operator functions, 153
- [] (brackets) in array indexing, 429, 441
- , (commas), in variable declarations, 20, 367
- ... (ellipses) as iteration indicator, 234, 239
- ! (exclamation point). See exclamation point
- - (minus sign). See minus sign
- () (parentheses). See parentheses
- . (period or dot) in function calls, 108, 429
- {} (braces). See braces
- (quotation marks for indicating string literals), 497-498
- / (slash). See slash
- | (vertical bar or pipe). See vertical bar
- A
- abstract base classes, 220, 229-230
- abstract data types, 231
- active types, 101
- addition-assignment operator (+=), 48, 178-179, 430
- addition operator (+), 13, 430 with operator function, 154
- addresses as pointers, 54, 55, 57-58
- address operator (&), 28, 57, 58, 232-233, 429
- aggregates, 234-236
- aliases, 469
- ampersand (&)
- as address operator, 28, 57, 58, 232-233, 429
- as bitwise AND operator, 49, 430
- doubled (&&) as logical AND operator, 49, 430
- with equal sign (&=) as bitwise AND assignment operator, 430
- as reference operator, 134, 140, 141-142, 166, 468-472
- angle brackets
- double (<< and >>) as left- and right-shift operators, 49, 430
- double (<< and >>) as stream operators, 83-87, 401, 433-434
- double with equal sign (=<< and =>>) as left- and right-shift assignment operators, 430
- with equal sign (<= or =>) as comparison operators, 46
- with hyphen (->) as pointer operator, 115, 429
- single (< or >) as comparison operators, 46
- anonymous unions, 237-238
- arguments
- default values, 317-319
- references as, 470-471
- variability of lists, 530-532
- arithmetical operations
- with addition/subtraction/multiplication/division operators (+), 13, 430
- with pointer arithmetic, 443-445
- arrays
- multi-dimensional, 242-244
- one-dimensional, 240-242
- and pointers, 60-67
- syntax, 239
- ASCII coding convention, 68
- assignment expressions, 31, 245
- assignment operators, 48, 148, 161-166, 178
- overloading, 438-439
- with reference operator, 166
- assignment statements
- declaring variables and assigning values, 25-26
- as operator function, 161-166
- syntax, 25, 245
- associativity
- for class operators, 179
- of left- and right-shift operators, 87
- list for C++ operators, 428
- list for C operators, 428
- asterisk (*)
- with equal sign (*=) as multiplication-assignment operator, 48, 179, 430
- as multiplication operator, 25, 430
- as pointer-indirection operator, 57, 105, 392-393, 429
- with slash (/*....*/) as begin- and end-comment symbols, 28
- A-to-Z reference guide, 14, 229
- at sign (@) with operator functions, 153
- auto keyword, 246
- auto variable, 496
- B
- backslash (\)
- double (\\) in path names in C quoted strings, 96
- as escape sequence character, 27
- base classes
- abstract, 220, 229-230
- access specifiers, 250
- constructors, 200-202, 252-255
- described, 182, 188, 247
- examples, 248, 249
- pointers, 203-206, 250-251
- syntax, 247, 248
- virtual, 211, 533-535
- binary operators
- considerations for operator functions, 154
- as friends, 160
- operator functions, 176
- overloading, 438
- bit fields, 256-261
- bitwise operators, 48-49, 262
- black box concept, 7-8
- Boolean values, 263-264
- braces ({}), 18
- for compound statements, 45, 283
- no semicolon after, 29, 30, 35, 106
- brackets ([]) in array indexing, 429, 441
- break statements, 265-266, 411
- bugs. See debugging
- C
- C++ programming language
- advantages, 2, 15-16
- future of, 15
- origins and development, 2
- See also debugging; sample code; syntax; transitioning from C to C++
- callback functions, 11, 538
- capitalization, 18
- caret (^)
- as bitwise exclusive OR (XOR) operator, 430
- with equal sign (^=) as bitwise XOR assignment operator, 430
- case keyword, 271-272
- case sensitivity of identifiers, 377-378
- casts
- explicit type conversions, 273, 355-359
- implicit type conversions, 388-389
- type, 273
- catch blocks, 348-350, 351, 354
- cat function, 120, 122
- CAuto class, 197-198, 253
- C/C++ icon, 13, 15
- CFontIoStr
- deriving from CIoStr, 189-190
- private member access, 194
- char* function, passing CStr with con-version function, 167-169
- char arrays, 68, 69
- char data type, 274-275, 309
- chips
- as objects, 6, 7
- virtues of independence and ignorance, 7-8
- cin objects
- advantages of gets, 90-91
- described, 85-87, 276-277
- formatting decimal, hex or octal numbers, 86
- versus scanf function, 97-98, 276
- C in Plain English, 14
- CIoStr class
- creating as shell around CStr object, 190-194
- deriving from CStr, 184-185
- function definitions, 185-186
- function inheritances, 186 function overrides, 186-188
- with object containment, 193-194
- object declarations, 185
- public/protected member-access, 194-195
- classes
- advantages of private functions, 103
- chips make and model as, 6
- clients of, 192
- as code and data, 7
- compared to structures, 128
- for control to data/function sharing, 8
- declarations requiring semicolon after brace, 106
- deriving (inheritance), 182-183, 328
- described, 3, 101, 102, 129-130, 278
- encapsulation, 9, 119, 129, 278, 337-339
- linking of declarations and function definitions by class name, 105
- names, 107
- reusing and publishing, 130-131
- run-time type information (RTTI), 478-480
- storage, 496
- string, 102-103
- syntax, 279-280
- as type, 9, 101
- typedef operators with, 520-521
- See also base classes; inheritance; overloading
- class keyword, 102
- class templates, 507, 508-510
- clients of classes, 192
- CMenu class
- declaring/defining base class, 212-213
- declaring/defining menu objects, 213-215
- described, 212
- implementing Do_Command, 219-220, 229-230
- objects, 215-217
- virtual functions, 217-219
- code
- exception handling, 346-354
- as instructions to computers, 5
- segregation from data, 5, 6, 110-111
- source code of published functions or classes, 182, 190
- See also compiling; sample code; syntax
- collection classes with templates, 507, 510
- colons
- in class argument lists, 202
- double (::) as context or scope opera-tor, 103-104, 299-300, 429
- commas (,), in variable declarations, 20, 367, 430
- comments
- /*....*/ (begin- and end-comment symbols), 20, 281
- // (begin comment line symbol), 20, 281, 282
- described, 281
- examples, 282
- with #if directive, 379, 382
- ignored in compiling, 20
- and labels, 410-411
- nesting, 282
- syntax, 281
- communtativity for class operators, 179
- comparisons
- Boolean values, 263-264
- caution on use of assignments in, 32-33
- operators, 46
- compiling
- comments ignored, 20
- C programs as C++ programs, 4, 13
- described, 19
- implementation files for publishable language extensions, 131
- compound control structures, 45
- See also loop processing
- compound statements, 29, 45, 283-284, 489
- conditional compilation
- #ifdef directive, 386
- #if directive, 379-381
- #ifndef directive, 387
- conditional tests
- caution on use of assignments in, 32
- #elif directive, 334
- else keyword, 44, 335
- #endif directive, 340
- operator (?:), 285-286
- with switch statements, 489, 501-506
- See also loop processing; testing
- constants
- aggregates, 234-236
- declaring, 25, 26
- with #define directive, 320-323
- described, 292
- storing, 293
- syntax, 292
- const char* function, passing CStr with conversion function, 169
- const keyword, 287-291
- constructors
- absence of returns, 125
- base-class, 200-202, 252-255
- blank argument lists, 125
- calls to, 147-149
- copy, 133, 138-145, 150, 156, 297-298
- default, 296
- default or hidden, 136-138, 150
- described, 115, 124, 294
- examples, 145-147
- naming, 124, 134
- overloading, 134-135, 149
- syntax, 294-295
- containment of objects, 192, 193
- context operator (::), 299-300
- continue statement, 301-303
- control structures
- compound, 45
- described, 43
- See also loop processing
- conversion functions, 167-169, 304-305
- conversion of types
- and constructors, 148-149, 151
- conversion functions, 167-169, 304-305
- unsigned data, 527-529
- copy constructors, 133, 138-145, 150, 156, 297-298
- cout objects
- described, 85-87, 277, 306
- examples, 307
- syntax, 306
- versus printf, 97-98
- .CPP files, suggestions for publishable language extensions, 131
- C programming language
- compilation considerations, 4, 13
- See also transitioning from C to C++
- cpy function, 120, 121
- CRateCar class, 199-200
- CShape class, 222-224
- CSportsCar class
- base-class constructors, 200-202, 253-255
- defining, 198-199
- CStr class
- addition (+) operator function for concatenating strings, 154-158
- addition/subtraction assignment operator, 178-179
- advantages, 169
- assignment operator function, 161-166
- calls from shell, 190-194
- constructor calls, 147-149
- constructors, 135-136
- conversion function, 167-169
- copy constructors, 133, 138-145, 156
- CSTR.CPP file, 170-173
- CSTR.H file, 170
- declarations, 104-105
- default constructors, 136-138
- deriving classes from (inheritance), 182-185
- deriving class function overrides, 186-188
- deriving class functions, 185-186
- dynamic-memory management, 117-119, 120-123
- friend keyword, 154, 158-161
- function/operator summary, 183
- inheritance hierarchies, 188-190
- inline functions in place of encapsulation, 126-128
- member function calls, 108-112, 113-114
- memory leaks, null pointers and constructors/destructors, 123-126
- passing to char* function with conversion function, 167-169
- pointer use, 116-120
- public/protected member-access, 194-197
- as publishable language extension, 130-131, 181-182
- requirements, 169-170
- string creation, 106-107
- type conversion, 148-149, 151
- See also CFontIoStr; sample code
- CSTR.H file, 185, 198
- CSTR.OBJ file, 198 CTemp_point example
- class declarations, 114
- described, 112
- operator functions, 173-175
- CTimePiece class, 208-210
- CTYPE.H header file, 23
- current object, 164
- CWagon class, 199
- .CXX files, suggestions for publishable language extensions, 131
- D
- data
- flows as streams, 81-82
- organization and structuring, 5
- pointing for access to, 54
- as raw information, 5
- segregation from code, 5, 6, 110-111
- data abstraction, 308
- data declarations, 24
- data members, 110
- static, 493-494
- See also member functions
- data types
- abstract, 231, 308
- char, 274-275
- characteristics, 21
- double, 21, 309, 332-333
- list of, 309
- primitive, 458
- See also types
- debugging
- advantages of default constructors, 137
- advantages of encapsulation for avoiding, 119-120
- caution on mixing I/O techniques, 84, 89, 97-98
- caution on setting initial and terminating conditions of loops, 62
- caution on string handling code rewrites, 116
- caution on use of assignment (=) in place of test-for-equality (==), 33
- exception handling, 346-354
- loops, 415
- scanf function, 484
- declarations
- compared to definitions, 324-325
- described, 310
- examples, 311-312
- prototypes and pointers, 312-315
- requiring semicolon after brace, 106
- storage class modifiers, 315-316
- syntax, 310-311
- See also classes
- decrement operators, 47
- overloading, 439-441
- default argument values, 317-319
- default constructors, 136-138, 150
- #define directive, 320-323, 325, 376
- typedef operator with, 521
- definitions, compared to declarations, 324-325
- delete operator
- call to constructors and destructors, 326
- described, 77-78, 326-327, 429
- overloading, 441-442
- return of pointer, 73, 115
- deriving classes, 328
- See also inheritance
- destractors, 115, 122, 125-126, 329-330
- directives
- with pound sign, 22
- without semicolon, 29
- display screen standard output (cout), 85-87
- division-assignment operator (/=), 48
- division operator (/) with operator function, 154
- Do_Command function, 219-220, 229-230
- do statement, 331
- double arguments (%1f) for scanf function, 28
- double data type, 21, 309, 332-333
- dynamic_cast operator, 429, 478-479
- dynamic memory, 73
- E
- #elif directive, 334
- ellipses (...) as iteration indicator, 234, 239
- else keyword, 44, 335
- empty statements (;), 336
- encapsulation, 9, 119, 129, 278, 337-339
- #endif directive, 340
- enum declarations, 341-345, 376
- EOF checks, 94
- equal sign (=)
- as assignment operator, 31, 148, 161, 430
- doubled (==) as equality/comparison operator, 32-33, 46, 430
- with exclamation point (=!) as not equal comparison operator, 430
- for variable initialization, 20, 25, 148
- errors. See debugging
- escape sequences, 27
- event-driven programs, 3
- exception handling, 346-354
- exclamation point (!)
- with equal sign (!=) as comparison operator, 46
- as logical NOT operator, 49, 429
- executable statements, 24
- explicit type conversions, 355-359
- expressions, 31-33, 47, 360, 488 postfix and prefix, 47
- extensions (filename)
- .H, 23
- .OBJ, 23
- external variables, 41-43
- extern C declarations, 361
- extern declarations, 42, 315, 316, 362-363
- in header files, 42, 316, 376
- F
- fclose function, 92
- fgetc function, 93, 94, 95
- fgets function, 92
- filename extensions. See extensions (filename)
- files
- implementation, 131
- as streams, 82-83
- See also header files
- float data type, 21, 364-365
- double, 333, 364, 365
- floating-point values, 21, 293
- fopen function, 92, 93
- form function in decimal, hex or octal formats, 89
- for statement, 366-367
- fprintf function, 92
- fputs function, 92
- fread function, 95
- free function, 74, 77, 120
- friend functions, 154, 158-161, 368-370
- fscanf function, 92
- fseek function, 95
- FSTREAM.H header file, 96, 97, 276
- function definitions
- entering prototypes and headings for, 35
- with local variables declaration, 38-89
- function prototypes, 35, 372
- void keyword, 539
- functions
- argument list variations, 530-532
- callback, 11
- choosing header file to use with, 23
- for derived classes, 185-186
- described, 33, 371
- friend, 154, 158-161, 368-370
- as hierarchical organizations of code, 5
- inline, 126-128, 210, 396-398
- main, 39
- member. See member functions
- overloading, 12, 134, 435
- overrides, 186-188
- pointers to, 453-456
- requirement to declare, 22
- returning values, 36
- static, 492-493
- syntax, 34-38, 371-873
- void, 37-38
- See also virtual functions
- function templates, 511-514
- fwrite function, 95
- G
- get function, 104, 400
- getline function, 96, 400
- gets function, 90, 91-92, 93-95
- global objects, 124
- global variables, 39-40, 124
- caution on use of, 54
- glossary. See A-to-Z reference guide; individual terms
- goto statements, 374
- with labels, 410-411
- graphical user interface (GUI) systems, 11
- H
- header files
- described, 22, 375-376
- example of use of two, 36
- extern declarations in, 42
- list of commonly used, 23
- suggestions for publishable language extensions, 131
- hexadecimal representation, 50-51, 88-89
- .H filename extensions, 23
- hierarchies (inheritance), 11, 188-190
- I
- icons
- C/C++, 13, 15
- NOTE, 14
- TIP, 15
- identifiers, 377-378
- #ifdef directive, 386
- #if directive, 379-382
- if-else statements, 43-45, 383-385
- conditional operator (?:), 285-286
- See also loop processing
- #ifndef directive, 387
- ifstream objects, 399
- ifstream stream objects, 95, 96
- implementation files, suggestions for publishable language extensions, 131
- implicit type casts, 388-389
- #include directives
- described, 390
- header file references, 22-23
- placement, 24
- reasons for, 22
- syntax, 22, 24, 390-391
- increment operators, 47
- overloading, 439-441
- indexes for arrays, 239, 241
- indirection, 55, 208, 221-222, 392-393
- indirection operator (*), 57, 105, 392-393
- inheritance
- advantages, 181, 394
- base-class constructors, 200-202
- base-class pointers, 203-206
- deriving classes, 182-185
- deriving class function overrides, 186-188, 211
- deriving class functions, 185-186
- deriving types into family trees of classes, 197-200
- example, 394-395
- versus containment, 193
- inheritance hierarchies, 11, 188-190
- initializing pointers, 448-450, 451-452
- initializing variables
- member, 123-124
- when declaring, 20, 25-26
- inline functions, 126-128, 210, 396-398
- in place of encapsulation, 126-128
- virtuality disallowed, 210
- input. See I/O operations
- instantiation of objects, 130, 220
- int data type, 21, 309, 403-404
- integers
- as ASCII character code, 68
- in decimal, hex or octal formats, 88-89
- described, 21
- as variables with use of bitwise operators, 49
- interchangeability
- virtues for chips, 7-8
- virtues for software modules, 8
- interfaces
- as connecting links between software modules, 8
- as public functions, 196
- versus internals as encapsulation, 9, 119
- I/O operations
- advantages of streams, 81-83, 97-99
- caution on mixing techniques, 84, 89, 97-98
- file operations, with STDIO.H, 92-95
- line-based, with STDIO.H, 89-92
- printing value of variables, 26
- printing with formatting, 21
- printing with stream operators, 27
- sequential versus random access, 92-95
- simple printing, 17-19
- IOSTREAM.H header file
- described, 23
- and FSTREAM.H, 96
- use of, 85, 86, 276
- istream class, 399-402
- J
- jump statements, 489
- K
- keyboard standard input (cin), 85-87
- keywords, 405
- L
- labels, 410-411
- late binding, 206, 208, 536
- left- and right-shift operators, 49
- versus commutativity for class operators, 180
- library functions, header files to include, 23
- line breaks
- in code, 18
- in print operations (newline character), 26-27
- linkage
- by collection classes with templates, 507, 510
- type-safe, 12, 269
- lists
- with enum declarations, 341-344
- with templates, 507
- literals (string), 497-498
- local objects, 124
- local variables, 38-39, 124
- logical operators, 49
- long arguments (%1d) for
- scanf function, 28
- long data type, 21, 309, 412-413
- loop processing
- arrays, 239
- continue statement, 301-303
- described, 414-415
- exiting with break statement, 265-266
- for statement, 366-367
- if-else statements, 43-45, 285-286, 383-385
- pointers, 64-67
- stream objects, 96
- while statements, 45-46, 366, 544-545
- See also conditional tests; testing
- 1-values, 406-409
- M
- macros with #define directive, 322-323
- main functions
- with and without arguments, 417-418
- described, 39, 416
- with return value, 93
- syntax, 416
- malloc function, 73, 74-77
- in CStr class, 119, 120
- new and delete preferred to, 115
- MALLOC.H header file, 23, 74
- MATH.H header file
- described, 23, 375
- example of use, 36
- member functions, 96, 103-114, 194-197
- const objects as, 291
- static, 494-495
- See also data members
- memory
- dynamic, 73
- importance of freeing, 77
- menus, polymorphic, 20
- minus sign (-)
- with angle bracket (->) as pointer operator, 115, 429
- double () as postfix decrement operator, 429
- with equal sign (-=) as assignment operator, 178-179, 430, 443
- as subtraction/negative operator, 13, 429, 430
- modules
- described, 41, 362
- interfaces as connecting links between, 8
- use of external variables for use by, 41-43, 362-363
- virtues of interchangeability for, 8
- modulus operator (%), 419
- multiplication-assignment operator (*=), 48, 179
- multiplication operator (*), 25 with operator function, 154
- N
- namespaces, 420-422
- naming
- with identifiers, 377-378
- operator functions, 176
- variables, 19
- nesting
- comments, 282
- control (if/else) statements, 44-45, 335
- loops, 303
- newline character (\n), 26-27
- new operator
- advantages of default constructors, 137, 150
- call to constructors and destructors, 326
- described, 77-78, 423-425, 429
- overloading, 441-442
- return of pointer, 53, 73, 114, 115
- NOTE icon, 14
- null bytes as terminators of strings, 68
- null pointers, 449, 450
- null statements, 489
- O
- object-oriented programming, 1-2
- classes of objects, 4-7
- independence of objects (polymorphism), 9-11
- objects
- behavior created by class declaration, 108, 109
- containment, 192, 193
- conversion functions, 167-169, 304-305
- creating, 107-108
- current, 164
- deleting, 73, 77-78, 115, 326-327, 429
- described, 426-427
- global, 124
- as instances of class type, 9, 108, 130
- instantiation, 130
- local, 124
- pointers to, 114-115
- stream, 81
- .OBJ filename extensions, 182
- ofstream stream objects, 95, 96
- operator functions
- assignment, 178-179
- associativity, precedence and commutativity, 179-180
- binary operators, 176
- calling, 156-157
- CStr class examples for concatenating strings, 154-158, 161-166
- CTemp example, 173-175
- described, 153
- naming, 176
- syntax, 153-155
- this keyword, 160, 164-165, 175-176
- unary operators, 177
- operator overloading
- assignment operator functions, 438-439
- binary operator functions, 438
- described, 12-13, 153, 436
- flexibility, 153
- function call operator, 442
- increment and decrement, 439-441
- left- and right- shift as examples of, 86
- new and delete, 441-442
- subscript, 441
- syntax, 436-437
- unary operator functions, 437-438
- operators
- assignment, 48, 148, 161-166, 178
- bitwise, 48-49
- conditional (?:), 285-286
- context (::), 299-300
- description and lists, 428-430
- increment and decrement, 47
- left- and right-shift, 49
- logical, 49
- modulus, 419
- reference (&), 134, 140, 141-142, 166
- See also delete operator; new operator
- ostream class, 399, 431-434
- output. See I/O operations
- overloading
- compared to virtual functions, 207
- constructors, 134-135, 149
- described, 12, 134-135, 153
- functions, 12, 134, 435
- operators. See operator overloading
- stream operators, 98, 401-402, 433-434
- overriding functions, 186-188
- pointer use, 204-206
- virtual functions as, 211
- P
- parentheses (())
- for clarification of loop statements, 65
- in function calls, 429
- overloading, 442
- passing by reference, 56-60
- peek function, 400
- percent sign (%)
- with equal sign (%=) as remainder assignment operator, 430
- as remainder operator, 430, 475-476
- performance considerations
- inline functions, 398
- of virtual functions, 211, 221-224
- period or dot (.) in function calls, 108, 429
- plus sign (+)
- as addition/positive operator, 13, 86, 429, 430
- double (++) as prefix increment operator, 429
- with equal sign (+=) as addition-assignment operator, 48, 178-179, 430, 443
- pointer arithmetic, 443-445
- pointers
- address expressions, 446-448
- advantages, 53, 446
- and arrays, 60-67
- asterisk (*) as pointer-indirection operator, 57, 105, 392-393, 429
- base-class, 203-206
- to const variables, 288-289
- described, 53, 54
- for dynamic memory handling, 73-79
- to functions, 453-456
- initialization, 448-450
- initialization and aggregates, 451-452
- for loop processing, 64-67
- to objects, 114-115
- passing by reference, 56-60
- for string handling, 72-73
- syntax, 446
- void keyword, 539
- polymorphism, 9-11, 457
- postfix and prefix expressions, 47
- precedence of, 65, 66
- pound sign (#) in directives, 22
- precedence
- for class operators, 179
- of left- and right-shift operators, 87
- of postfix expressions, 65, 66
- primitive data types, 458
- printf function
- advantages of format specifiers, 89-90
- caution on mixing I/0 techniques, 84, 97-98
- comparison to stream operators, 84-85
- described, 21, 26, 459
- format modifiers, 460-461
- formats, 459-460
- format symbols by data type, 21
- syntax, 459
- private base classes, 184, 247, 249, 250, 462, 463
- private data types, 128
- private members, 8, 194-197, 462
- programming languages
- C++, 2, 3, 4
- development, 1
- object-oriented, 1-2
- Simula, 3
- Visual Basic, 2
- protected base classes, 247, 249, 250, 465
- protected member access, 194-197, 464
- public base classes, 184, 247, 467
- public data types, 128
- public members, 9, 194-197, 466
- punctuation, 18
- putchar function, 400
- puts function, 90, 93-95
- Q
- question mark with colon (?:) as conditional operator, 430
- quotation marks () for indicating string literals), 497-498
- R
- random access file handling, 95
- reading
- with read function, 400
- See also scanf function
- reference operator (&), 134, 140, 141-142, 166, 468-472
- register keyword, 473-474
- remainder operators (% and %=), 430, 475-476
- reserved words (keywords), 405
- return statements, 36, 477
- return values, references as, 471-472
- right- and left-shift operators, 49
- RTTI (run-time type information), 478-480
- run-time type information (RTTI), 478-480
- S
- sample code (in order of presentation)
- printing simple string, 17-19
- printing formatted out-put, 21
- assigning values, 25-26
- printing value of variables, 26
- printing with stream operators, 27
- prompting for input, 28
- use of semicolons, 30
- multiple assignments, 31-32
- Pythagoras function call, 34
- Pythagorus function call illustrating syntax and return statement, 35-37
- calling void function, 37-38
- Pythagoras function call with main local variables declaration, 39
- Pythagoras function call with global variables declaration, 40
- static variable as private to single function, 41
- external variable declarations in header files, 42
- nested control (if/else) statements, 44-45
- compound control (if/else) statements, 45
- while statements, 46
- while statements with decrement operator, 47
- assignment operators with calculations, 48
- bitwise and left-shift operators to print binary representations, 50-51
- passing by reference, 57, 58, 59, 60
- declaring arrays or variable indexes, 63-64
- loop processing of arrays, 64
- loop processing with pointers, 64-67
- copying strings, 71-72
- malloc function, 73, 74-77
- memory allocation with new operator, 77-78
- memory freeing with delete operator, 78-79
- getting and printing sum of floating-point numbers, 84-85
- more compact version of previous code, 86-87
- inputting line with gets and assigning fields to strings, 91-92
- printing text file and converting all lower to uppercase, 93-94
- printing file contents, 97
- defining member functions, 103-106
- inheritance trees, 197-200
- base-class constructors, 200-202
- base classes and pointers, 203-206
- virtual functions, 209-210
- virtual function indirect calls, 221-224
- virtual functions for menu commands, 212-220
- See also CFontIoStr; CIoStr class; CMenu class; CStr class
- scanf function
- advantages of format specifiers, 89-90
- advantages of gets, 90-91
- caution on mixing I/0 techniques, 84, 97-98
- comparison to stream operators, 84-85, 399
- debugging, 484
- described, 27-28, 481
- format modifiers, 483
- format specifiers, 482
- format symbols by data type, 21
- other characters with, 483
- syntax, 481
- scope of variables, 38, 485
- scope operator (::), 103-104
- screen display standard output (cout), 85-87
- semicolon (;)
- after brace in class, struct and union declarations, 106
- in empty (null) statements, 336
- non-use with directives (such as #include), 22, 29
- not used after braces ({}), 29, 30, 35, 106
- terminating function prototype statements with, 35
- terminating statements with, 18, 29
- in variable declarations, 19, 25
- sequential file I/O, 92-95
- short data type, 21, 309, 486-487
- signed char data type, 309
- Simula programming language, 3
- single data type, 309
- sizeof operator, 429
- slash (/)
- with asterisk (/*....*/) as begin- and end-comment symbols, 20
- as division operator, 430
- as division operator with operator function, 154
- doubled (//) for comment lines, 20, 281, 282
- with equal sign (/=) as division assignment operator, 430
- source code
- of published functions or classes, 182, 190
- See also compiling, CStr class; sample code
- spacing, 18
- stacks, 55
- and auto keyword, 246
- collection class template, 510-511
- standard input/output, 82
- See also cin objects; cout objects
- standard library, 23
- statements
- compound, 29, 45, 283-284, 489
- described, 24
- expression, 31-33, 47, 360, 488
- jump, 489
- labels for, 410-411
- null, 489
- switch, 271-272, 410, 411, 489, 501-506
- syntax, 488-490
- versus expressions, 360
- See also assignment statements
- static data members, 493-494
- static functions, 492-493
- static keyword, 491-499
- static member/unctions, 494-495
- static variables, 40-41, 492, 496
- STDIO.H header file
- described, 22, 23, 375
- file operations, 92-95
- line-based input, 89-92
- stream operator alternatives, 83
- storage classes, 496
- strcat function, 71
- strcpy function, 68, 70
- stream objects, 81
- creating, 96
- files as, 82-83
- ifstream, 95
- ofstream, 95
- stream operators
- advantages for I/O operations, 14, 81-83, 97-99
- angle brackets (<< and >>} as, 83-87
- caution on mixing I/O techniques, 84, 97-98
- comparison to scanf function, 84-85, 399
- direction of data flows, 85-86
- example, 27
- file handling, 95-97
- overloading, 98
- See also cin objects; cout objects
- string classes, 102-103
- string handling
- in Basic versus C, 102
- caution on code rewrites, 116
- creating for CStr class, 106-108
- STRING.H header file, 23, 71
- string literals, 497-498
- strings
- aggregates, 234-236
- char data type, 274-275
- concatenating with addition operator, 13
- concatenating with operator functions (overloading), 153-156
- copying, 70-71
- creating, 70
- described, 68
- determining length of, 68-69
- passing to char function with conversion function, 167-169
- terminated with null bytes, 68
- string types, 101-102
- str1en function, 71
- strncpy function, 71
- Stroustup, Bjarne, 3
- struct declarations
- declaring variables, 107
- described, 499-500
- in header files, 376
- public versus private, 128
- requiring semicolon after brace, 106
- structures, compared to classes, 128
- subtraction-assignment operator (-=), 48, 178-179
- subtraction operator (-), 13, 430
- with operator function, 154
- switch statements, 489, 501-506
- case keyword, 271-272
- labels for, 410, 411
- symbolic constants, with #define directive, 320-322
- syntax
- for arrays, 61
- for assignment statements, 25, 245
- for base classes, 247, 248
- capitalization, 18
- for classes, 279-280
- for comment lines, 20, 281, 282
- for constants, 292
- for constructors, 294-295
- for directives, 22, 29
- for functions, 34-38, 371-373
- idiosyncrasies of C++, 14, 17, 29-33
- for operator functions, 153-155
- for operator overloading, 436-437
- period or dot (.) in function calls, 108, 429
- for pointers, 446
- punctuation, 18
- spacing and line breaks, 18
- for statements, 488-490
- for variables, 19-20
- See also ampersand; angle brackets; asterisk; braces; equal sign; individual topics; minus sign; parentheses; precedence; sample code; semicolon
- T
- templates, 507-514
- testing
- bits with bitwise operators, 49
- for EOF, 94, 95
- memory allocations or freeings, 76, 79
- See also loop processing
- this keyword
- described, 515-516
- examples, 516-517
- as pointer to current object, 160, 164-165, 175-176
- throw statements, 352
- tilde (~)
- as bitwise NOT operator, 49
- as destructor name prefix, 124, 329
- TIP icon, 15
- transitioning from C to C++
- anonymous unions, 237-238
- begin- and end-comment symbols (/* and */), 20
- C/C++ icon, 13, 15
- code porting guidelines, 267-270
- ease of, 4
- extern C declarations, 361
- idiosyncrasies of C++ syntax, 14, 17
- I/O with STDIO.H, 89-95
- mixing declarations and statements, 24
- placement of data/variable declarations, 24
- pointers and data types, 76
- recommended reading, 14
- simplified variable declarations, 107
- stream objects, 81
- void main keyword requirement, 19, 267, 268
- TRUE/FALSE comparisons (Boolean values), 263-264
- try blocks, 348-350, 351
- type casts, 273
- explicit, 355-359
- implicit, 388-389
- void keyword, 539
- typedef declarations, 107, 376
- typedef operators, 518-521
- typeid operator, 429, 479-480
- type names in variable declarations, 19
- types
- abstract, 231, 308
- active, 101
- C++ strengthened handling of, 11-12
- of classes, 9
- conversion and constructors, 148-149, 151
- deriving through inheritance, 197-200
- explicit conversions, 355-359
- providing information with function prototypes, 35
- string, 101-102
- use with function overloading, 12
- use with operator overloading, 12-13
- See also casts
- type-safe linkage, 12, 269
- U
- unary operators
- operator functions, 177
- overloading, 437-438
- union declarations
- anonymous (unnamed), 237-238
- declaring variables, 107
- described, 522
- examples, 523-525
- in header flies, 376
- public versus private, 128
- requiring semicolon after brace, 106
- syntax, 522
- unsigned data types, 309, 526-529
- V
- values
- assigning, 25-26
- 1- (left), 406-409
- returned by functions, 33 same, assigning to multiple variables, 31
- variables
- allocating to registers, 473-474
- const keyword, 287-288
- declaring 19-22, 24
- declaring multiple, 20
- declaring with const keyword, 287-291
- with enum declarations, 344-345
- external, 41-43
- global, 39-40, 124
- incrementing and decrementing, 47
- initializing when declaring, 20
- local, 38-39, 124
- manipulating with statements, 24-25
- scope of, 38, 485
- static, 40-41, 492, 496
- uses for storing/manipulating data, 19
- visibility, 485
- vertical bar (|) (pipe character)
- as bitwise OR operator, 49, 430
- doubled (||) as logical OR operator, 49, 430
- with equal sign (|=) as bitwise OR assignment operator, 430
- virtual base classes, 211, 533-535
- virtual functions
- advantages, 11, 203, 207-208
- compared to callbacks, 538
- compared to overloading, 207
- described, 536-538
- implementation and performance considerations, 221-224
- late binding, 206, 536
- menu command example, 212-219
- overrides, 188, 536
- pure (no implementation), 219-220
- syntax, 208
- when to use, 210-211
- virtual function tables, 222
- visibility of variables, 485
- Visual Basic, 2
- void functions, 37-38
- void keyword, 539-540
- void main statement, 19
- volatile keyword, 541-543
- W
- while statements, 45-46, 366, 544-545
[an error occurred while processing this directive]
|