Keywords¶
This page lists all of the C++ keywords, and either links to a reference page explaining their use, or provides a brief description.
List of Keywords¶
The C++ keywords are:
and, and_eq, asm, auto, bitand, bitor,
bool, break, case, catch, char, class,
compl, const, const_cast, continue, default,
delete, do, double, dynamic_cast, else, enum,
explicit, export, extern, false, float, for,
friend, goto, if, inline, int, long,
mutable, namespace, new, not, not_eq,
operator, or, or_eq, private, protected,
public, register, reinterpret_cast, return, short,
signed, sizeof, static, static_cast, struct,
switch, template, this, throw, true, try,
typedef, typeid, typename, union, unsigned,
using, virtual, void, volatile, wchar_t,
while, xor, xor_eq
Boolean Operator Synonyms¶
Bitwise Operator Synonyms¶
Constants¶
trueandfalseare the boolean constants.
Control Flow¶
breakcan exit out of a switch statement or a for, do, or while loop.casedefines alternatives in a switch statement.continuewill move control flow to the next iteration of the enclosing for, do, or while loop.defaultdefines the default alternative in a switch statement.dointroduces a do loop.elseis used in if statements.forintroduces a for loop.gotojumps to a label.ifintroduces an if statement.returntransfers flow to a function’s caller.switchintroduces a switch statement.whileintroduces a while loop.
Types¶
The following keywords are used for built-in types.
The following keywords are used to introduce new types.
Qualifiers¶
- static can be used to declare persistent local variables; it has other uses not documented here.
unsignedis used to specify an unsigned integral type. Examples: unsigned int, unsigned char.- volatile is useful when declaring variables that may be modified by external interrupts.
- const is used to define constants.
Other¶
These keywords are not described in the Maple documentation. For more information, consult a C++ reference.
asmis used to insert literal assembly language.autois used to declare that a variable has automatic storage.catchis used in exception handling. Note that the default flags we pass to GCC include-fno-exceptions.classis used to define classes.const_castis used in typecasting.deleteis used to freenew-allocated storage. Note that dynamic memory allocation is not available by default on the Maple, so you’ll have to bring your ownnewanddeleteif you want this.dynamic_castis used in typecasting.explicitis used to declare constructors that can be called only explicitly.exportdeclares a template definition accessible to other compilation units.externcan mark a declaration as a declaration and not a definition, and also grant external linkage to aconstortypedef.friendis used to declare that certain functions have access to a class’s private variables.inlineis a compiler hint to inline a function.mutablespecifies that a member can be updated, even when a member of aconstobject.namespacedeclares a new namespace.newdynamically allocates space for a value. Note that dynamic memory allocation is not available by default on the Maple, so you’ll have to bring your ownnewanddeleteif you want this.operatoris used to define type-specific operator overrides.privatedeclares a private class member.protecteddeclares a protected class member.publicdeclares a public class member.registeris a compiler hint to store a variable in a register.reinterpret_castis used in typecasting.signedis the opposite ofunsigned.static_castis used in typecasting.structdeclares a new struct.templateintroduces a template class, function, etc.thisis a pointer to the receiver object.throwis used in exception handling. Note that the default flags we pass to GCC include-fno-exceptions.tryis used in exception handling. Note that the default flags we pass to GCC include-fno-exceptions.typedefdefines a type synonym.uniondefines an untagged union.usingis a directive related to namespaces.virtualdeclares a method which may be overridden.wchar_tis the wide character type.