| Keyword | Used | Purpose |
| auto | Very infrequently | Defines a variable as 'automatic', that is, its memory is allocated by the compiler for the duration of its existence. For local variables this is the default anyway |
| break | All the time | The 'break' statment causes execution of the program to jump out of the current loop or 'case' statement. Use is almost compuslory with 'switch...case', and common with loops. However, the principles of structured programming suggest that use of 'break' to jump out of the middle of a loop should usully be avoided |
| bool | Infrequently; should be used more | 'bool' defines a variable as being of 'Boolean' type, i.e. able to take only 'true' or 'false' values. As C did not have a Boolean data type, many programmers have got used to using integers for this |
| case | All the time | Used with 'switch' to allow execution of one of a list of groups of statements |
| catch | Infrequently; not well understood | Used with 'try' and 'throw' to detect and process 'exceptions', that is, unusual circumstances like errors. The exception handling mechanism in C++ is not well understood by programmers |
| char | All the time | Indicates a character data type |
| class | All the time | Indicates that the following statements are the definition or declaration of a C++ class |
| const | All the time by good programmers | Indicates that a variable has a constant value, i.e., cannot be redefined; with a class operation, indicates that the operation does not modify the object's data |
| const_cast | Very infrequently | Changes the 'constant' or 'volatile' status of a data item |
| continue | Too often | Inside a loop, causes the rest of the statements after 'continue' to be skipped, and the next turn of the loop started. Use with caution. |
| default | All the time | Used with 'switch' to indicate the action that should be carried out if no others are appropriate |
| delete | All the time | Removes a data item that was constructed using 'new', freeing any memory it used |
| do | All the time | Used with 'while' to construct a loop that must be executed at least once |
| double | All the time | Indicates a real-number, double-precision value |
| dynamic_cast | Very infrequently | Used in management of class inheritance |
| else | All the time | Used with 'if' to execute statements according to the results of a comparison |
| enum | Not often enough | A data type whose possible values are listed explicitly, e.g., 'enum {red, amber, green} TrafficLightColour' |
| explicit | Infrequently | Prevents an object being intialized using a statement of the form 'X x=1', where x is an object of class X |
| extern | All the time | Indicates that something used in one program module (file) is defined in a different program module. |
| false | Not frequently enough | See 'bool' |
| float | All the time | Indicates a floating-point (real number) data element |
| friend | All the time | Within a class, indicates that a different class or function is to be allowed access to the class's data |
| for | All the time | Used to construct loops |
| goto | Infrequently | Jumps to a specified place in a function |
| if | All the time | Executes statements if a condition is true |
| inline | Commonly in specific contexts | Suggests to the compiler that a function should be inserted into the program whereever it is used, and not called as a function. This process is transparent to the programmer and does not change the result of the function; it makes some programs slightly faster at the expense of needing more memory |
| long | All the time | Indicates that a long version of a particular data type is to be used, i.e., one with a greater range of values |
| mutable | Infrequently | Indicates that a data element in an object can be changed, even by operations which claim not to change data |
| namespace | Infrequently, except in large applications | Defines a namespace, that is, a division of the program in which names will not be shared with other parts of the program |
| new | All the time | Creates a new variable or object |
| operator | Sometimes (or all the time by some programmers) | Used in extending the meanings of C++ operators |
| private | All the time | In a class, indicates an operation or attribute that is accessible only within the class (except as indicated by 'friend') |
| protected | All the time | In a class, indicates an operation or attribute that is accessible only classes of the same type (i.e., derived from this one) |
| public | All the time | In a class, indicates an operation or attribute that is accessible outside the class |
| register | Suggests to the compiler that a variable should be held in a CPU register and not in memory. This is for speed optimization. | |
| reinterpret_cast | Very infrequently | Used to improve the safety of certain types of cast operation |
| return | All the time | Exits a function, specifying the return value if appropriate |
| short | All the time | Indicates that a shorter version of a particular data type is to be used, i.e., one with a smaller range |
| signed | Infrequently | Indicates that the following data type is signed, i.e., accepts positive and negative values. In C++, integers are signed by default, so this keyword is uncommon |
| sizeof | All the time | When applied to a variable or data type, give the number of bytes used to store it |
| static | All the time | Various meanings, all concerned with the scope and lifetime of data and functions |
| static_cast | Very infrequently | Used in conversion between objects of different types |
| struct | All the time | Introduces a programmer-defined data structure |
| switch | All the time | Used with 'case' and 'default' to provide a mechanism where one of a list of sets of statements is executed |
| template | All the time by programmers that like templates, or use template libraries | Indicates that the following definitation is of a fucntion or class template, rather than a function or class |
| this | All the time | Used within an object to refer to the object itself |
| throw | Infrequently; not well understood | Used with 'try' and 'throw' to detect and process 'exceptions', that is, unusual circumstances like errors. The exception handling mechanism in C++ is not well understood by programmers |
| true | Not frequently enough | See 'bool' |
| try | Infrequently; not well understood | Used with 'catch' and 'throw' to detect and process 'exceptions', that is, unusual circumstances like errors. The exception handling mechanism in C++ is not well understood by programmers |
| typedef | All the time | Introduces a programmer-defined data type |
| typename | Infrequently | Used in the definition of general-purpose templates |
| typeid | Infrequently, except in certain contexts | Provides information about the type of an object |
| union | Increasingly uncommonly | Indicates that the same area of memory can be used to store a number of different variables at different times |
| using | Infrquent, except in large applications | Used with 'namespace' to distinguish between data in different namespaces |
| unsigned | All the time | Indicates that the following variable is unsigned, i.e., only takes positive values |
| virtual | All the time | In the definition of a class, indicates that an operation will be re-defined in classes derived from it |
| void | All the time | Indicates that something is unknown, or does not have a value, or does not accept parameters, or does not return a value |
| volatile | Infrequently, except in certain contexts | Indicates that a variable or object is liable to be modified by another part of the program in an unpredictable way. For example, in response to a background processing task |
| wchar_t | Infrequently | Indicates a 'wide charater', that is, a character type with a much greater range of symbols that the standard 'char' |
| while | All the time | Used to construct loops, alone or with 'do' |
©1994-2003 Kevin Boone, all rights reserved