ILE C/C++ Language Reference (C++ PDF)

This C++ tutorial covers the details of ILE C/C++ Language Reference.In this PDF couers the C/C++ Language Reference describes the syntax, semantics, and IBM implementation of the C and C++ programming languages. Syntax and semantics constitute a complete specification of a programming language, but complete implementations can differ because of extensions. The IBM implementations of Standard C and Standard C++ attest to the organic nature of programming languages, reflecting pragmatic considerations and advances in programming techniques, which are factors that influence growth and change. The language extensions to C and C++ also reflect the changing needs of modern programming environments.
Contents
About This Reference     vii
Highlighting Conventions    viii
Howto Read the Syntax Diagrams     viii
Chapter 1.
Scope and Linkage  1
Scope  2
Local Scope 3
Function Scope . 3
Function Prototype Scope . 3
Global Scope . 3
Class Scope . 4
Name Spaces of Identifiers . 4
Name Hiding . 5
Program Linkage . 6
Internal Linkage . 7
External Linkage . 7
No Linkage . 8
Linkage Specifications—Linking to Non-C++ Programs . 8
Name Mangling . 9
Chapter . 2 Lexical Elements . 11
Tokens . 11
Punctuators . 11
Alternative Tokens . 12
Source Program Character Set . 12
Escape Sequences . 13
The Unicode Standard . 14
Trigraph Sequences . 14
Multibyte Characters . 15
Comments . 15
Identifiers . 17
Reserved Identifiers . 18
Case Sensitivity and Special Characters in Identifiers . 18
Keywords . 18
Keywords for language extensions . 19
Alternative Representations of Operators and Punctuators . 19
Literals . 19
Boolean Literals . 19
Integer Literals . 20
Decimal Integer Literals . 20
Hexadecimal Integer Literals . 21
Octal Integer Literals . 21
Floating-Point Literals . 21
Packed Decimal Literals . 23
Character Literals . 23
String Literals . 24
Chapter 3. Declarations . 27
Declaration Overview . 27
The__align Specifier . 28
Objects . 29
Storage Class Specifiers . 29
auto Storage Class Specifier . 30
externStorage Class Specifier. 31
mutableStorage Class Specifier . 32
register Storage Class Specifier . 33
static Storage Class Specifier . 34
typedef . 35
Type Specifiers . 36
Type Names . 37
Compatible Types . 38
Simple Type Specifiers . 39
Boolean Variables . 39
char and wchar_t Type Specifiers . 40
The wchar_t Type Specifier . 40
Floating-Point Variables . 40
Packed Decimal Variables . 41
Integer Variables . 42
void Type . 43
Compound Types . 43
Structures . 44
Declaring and Defining a Structure . 45
Defining a Structure Variable . 46
Initializing Structures . 46
Declaring Structure Types and Variables in the Same Statement . 47
Declaring and Using Bit Fields in Structures . 48
Unions . 50
Declaring a Union . 51
Defining a Union Variable . 52
Anonymous Unions . 52
Enumerations . 54
Declaring an Enumeration Data Type . 54
Enumeration Constants . 54
Defining Enumeration Variables . 55
Defining an Enumeration Type and Enumeration Objects . 56
Type Qualifiers . 57
The const Type Qualifier . 59
Thevolatile Type Qualifier . 60
ILE Type Qualifiers . 60
The__ptr128 Qualifier . 60
The__ptr64 Qualifier . 61
The asm Declaration . 61
Incomplete Types . 61
Chapter 4. Declarators . 63
Initializers . 64
Pointers . 65
Declaring Pointers . 66
Assigning Pointers . 66
Initializing Pointers . 67
Using Pointers . 67
Pointer Arithmetic . 68
Arrays . 69
Declaring Arrays . 70
Initializing Arrays . 71
Function Specifiers . 75
References . 75
Initializing References . 76
Chapter 5. Expressions and Operators . 79
Operator Precedence and Associativity . 80
Lvalues and Rvalues . 83
Primary Expressions . 84
Identifier Expressions . 85
Integer Constant Expressions . 85
Parenthesized Expressions () . 86
C++ Scope Resolution Operator :: . 87
Postfix Expressions . 88
Function Call Operator () . 88
Array Subscripting Operator [] . 90
Dot Operator . 91
Arrow Operator -> . 91
The typeid Operator . 92
static_cast Operator . 93
reinterpret_cast Operator . 94
const_cast Operator . 95
dynamic_cast Operator . 96
Unary Expressions . 98
Increment ++ . 99
Decrement — . 99
Unary Plus + . 100
Unary Minus – . 100
Logical Negation ! . 100
Bitwise Negation ~ . 100
Address & . 101
Indirection * . 101
sizeof Operator . 102
C++ new Operator . 103
Initializing Objects Created with the new Operator . 106
set_new_handler()—Set Behavior for new Failure . 106
C++ delete Operator . 107
Cast Expressions . 108
Binary Expressions . 109
Multiplication * . 110
Division / . 111
Remainder % . 111
Addition + . 111
Subtraction – . 111
Bitwise Left and Right Shift <<>>. 112
Relational<><=>=. 112
Equality==!= . 114
Bitwise AND & . 115
Bitwise Exclusive OR ^ . 115
Bitwise Inclusive OR | . 116
Logical AND && . 116
Logical OR || . 117
C++ Pointer to Member Operators .*->* . 118
Conditional Expressions . 118
Type of Conditional C Expressions . 119
Type of Conditional C++ Expressions . 119
Examples of Conditional Expressions . 120
Assignment Expressions . 120
Simple Assignment = . 120
Compound Assignment . 121
Comma Expressions . 122
C++ throw Expressions . 123
Chapter 6. Implicit Type Conversions 125
Integral and Floating-Point Promotions . 125
Standard Type Conversions . 126
Lvalue-to-Rvalue Conversions . 126
Boolean Conversions . 127
Integral Conversions . 127
Floating-Point Conversions . 128
Pointer Conversions . 128
Reference Conversions . 129
Pointer-to-Member Conversions . 130
Qualification Conversions . 130
Function Argument Conversions . 130
Other Conversions . 130
Arithmetic Conversions . 131
The explicit Keyword . 132
Chapter 7. Functions . 135
C++ Enhancements to C Functions . 135
Function Declarations . 136
C++ Function Declarations . 138
Multiple Function Declarations . 138
Parameter Names in Function Declarations 139
Examples of Function Declarations . 139
Function Definitions . 140
Ellipsis and void . 144
Examples of Function Definitions . 145
The main() Function . 146
Arguments to main . 146
Example  of Arguments to main . 146
Calling Functions and Passing Arguments . 147
Passing Arguments by Value . 148
Passing Arguments by Reference . 149
Default Arguments in C++ Functions . 150
Restrictions on Default Arguments . 151
Evaluating Default Arguments . 152
Function Return Values . 153
Using References as Return Types . 154
Allocation and Deallocation Functions . 154
Pointers to Functions . 155
Inline Functions . 156
Chapter 8. Statements . 157
Labels . 157
Expression Statements . 158
Resolving Ambiguous Statements in C++ . 158
Block Statement . 159
if Statement . 160
switch Statement . 162
while Statement . 165
do Statement . 166
for Statement . 167
break Statement . 169
continue Statement . 169
return Statement . 171
Value of a return Expression and Function Value . 172
goto Statement . 172
Null Statement . 173
Chapter 9. Preprocessor Directives 175
Preprocessor Overview . 175
Preprocessor Directive Format . 176
Macro Definition and Expansion (#define) . 176
Object-Like Macros . 177
Function-Like Macros . 177
Scope of Macro Names (#undef) . 180
# Operator . 180
Macro Concatenation with the ## Operator . 181
Preprocessor Error Directive (#error) . 182
File Inclusion (#include) . 183
ISO Standard Predefined Macro Names . 184
Conditional Compilation Directives . 185
#if, #elif . 186
#ifdef . 187
#ifndef . 187
#else . 188
#endif . 188
Line Control (#line) . 189
Null Directive (#) . 190
Pragma Directives (#pragma) . 190
Chapter 10. Namespaces . 191
Defining Namespaces . 191
Declaring Namespaces . 191
Creating a Namespace Alias . 191
Creating an Alias for a Nested Namespace . 192
Extending Namespaces . 192
Namespaces and Overloading . 193
Unnamed Namespaces . 193
Namespace Member Definitions . 195
Namespaces and Friends . 195
Using Directive . 196
The using Declaration and Namespaces . 196
Explicit Access . 197
Chapter 11. Overloading . 199
Overloading Functions . 199
Restrictionson Overloaded Functions . 200
Overloading Operators . 201
Overloading Unary Operators . 202
 Overloading Increment and Decrement . 203
Overloading Binary Operators . 205
Overloading Assignments . 205
Overloading Function Calls . 207
Overloading Subscripting . 208
 OverloadingClass Member Access . 209
Overload Resolution . 209
Implicit Conversion Sequences . 210
Resolving Addresses of Overloaded Functions 211
Chapter 12. Classes . 213
Declaring Class Types . 213
Using Class Objects . 214
Classes and Structures . 215
Scope of Class Names . 216
Incomplete Class Declarations . 217
Nested Classes . 218
Local Classes . 220
Local Type Names . 221
Chapter 13. Class Members and Friends . 223
Class Member Lists . 223
Data Members . 224
Member Functions . 224
const and volatile Member Functions . 226
Virtual Member Functions . 226
Special Member Functions . 226
Member Scope . 226
Pointers to Members . 228
The this Pointer . 229
Static Members . 232
Using the Class Access Operators with Static Members . 232
Static Data Members . 233
Static Member Functions . 235
Member Access . 236
Friends . 238
Friend Scope . 240
Friend Access . 243
Chapter 14. Inheritance . 245
Derivation . 247
Inherited Member Access . 250
Protected Members . 250
Access Control of Base Class Members . 251
The using Declaration and Class Members . 252
Overloading Member Functions from Base and Derived Classes . 253
Changing the Access of a Class Member . 255
Multiple Inheritance . 256
Virtual Base Classes . 257
Multiple Access . 258
Ambiguous Base Classes . 259
Virtual Functions . 262
Ambiguous Virtual Function Calls . 266
Virtual Function Access . 267
Abstract Classes . 268
Chapter 15. Special Member Functions . 271
Constructors and Destructors Overview . 271
Constructors . 272
Default Constructors . 273
Explicit Initialization with Constructors . 274
Initializing Base Classes and Members . 276
Construction Order of Derived Class Objects 279
 Destructors . 280
Free Store . 283
Temporary Objects . 287
User-Defined Conversions . 288
Conversion by Constructor . 289
Conversion Functions . 291
Copy Constructors . 291
Copy Assignment Operators . 293
Chapter 16. Templates . 295
Template Parameters . 296
Type Template Parameters . 296
Non-Type Template Parameters . 296
Template Template Parameters . 297
Default Arguments for Template Parameters . 297
Template Arguments . 298
Template Type Arguments . 298
Template Non-Type Arguments . 299
Template Template Arguments . 300
Class Templates . 301
Class Template Declarations and Definitions . 303
Static Data Members and Templates . 303
Member Functions of Class Templates . 304
Friends and Templates . 304
Function Templates . 305
Template Argument Deduction . 306
Deducing Type Template Arguments . 309
Deducing Non-Type Template Arguments 310
Overloading Function Templates . 311
Partial Ordering of Function Templates . 312
Template Instantiation . 313
Implicit Instantiation . 313
Explicit Instantiation . 314
Template Specialization . 315
Explicit Specialization . 316
Definition and Declaration of Explicit Specializations . 317
Explicit Specialization and Scope . 317
Class Members of Explicit Specializations 317
Explicit Specialization of Function Templates 318
Explicit Specialization of Members of Class Templates . 318
Partial Specialization . 320
Template Parameter and Argument Lists of Partial Specializations . 321
Matching of Class Template Partial Specializations . 322
Name Binding and Dependent Names . 322
The typename Keyword . 323
The Keyword template as Qualifier . 324
Chapter 17. Exception Handling . 327
The try Keyword . 327
Nested Try Blocks . 329
catch Blocks . 329
Function try block Handlers . 330
Arguments of catch Blocks . 333
Matching between Exceptions Thrown and Caught . 333
Order of Catching . 334
The throw Expression . 335
Rethrowing an Exception . 335
Stack Unwinding . 337
Exception Specifications . 338
Special Exception Handling Functions . 341
unexpected() . 341
terminate() . 342
set_unexpected() and set_terminate() . 343
Example Using the Exception Handling Functions . 344
Notices . 347
Programming Interface Information . 349
Trademarks and Service Marks . 349
Industry Standards . 349
Index . 351.

View Source

Related Tutorials

Comments are closed.