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¶
true
andfalse
are the boolean constants.
Control Flow¶
break
can exit out of a switch statement or a for, do, or while loop.case
defines alternatives in a switch statement.continue
will move control flow to the next iteration of the enclosing for, do, or while loop.default
defines the default alternative in a switch statement.do
introduces a do loop.else
is used in if statements.for
introduces a for loop.goto
jumps to a label.if
introduces an if statement.return
transfers flow to a function’s caller.switch
introduces a switch statement.while
introduces 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.
unsigned
is 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.
asm
is used to insert literal assembly language.auto
is used to declare that a variable has automatic storage.catch
is used in exception handling. Note that the default flags we pass to GCC include-fno-exceptions
.class
is used to define classes.const_cast
is used in typecasting.delete
is 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 ownnew
anddelete
if you want this.dynamic_cast
is used in typecasting.explicit
is used to declare constructors that can be called only explicitly.export
declares a template definition accessible to other compilation units.extern
can mark a declaration as a declaration and not a definition, and also grant external linkage to aconst
ortypedef
.friend
is used to declare that certain functions have access to a class’s private variables.inline
is a compiler hint to inline a function.mutable
specifies that a member can be updated, even when a member of aconst
object.namespace
declares a new namespace.new
dynamically 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 ownnew
anddelete
if you want this.operator
is used to define type-specific operator overrides.private
declares a private class member.protected
declares a protected class member.public
declares a public class member.register
is a compiler hint to store a variable in a register.reinterpret_cast
is used in typecasting.signed
is the opposite ofunsigned
.static_cast
is used in typecasting.struct
declares a new struct.template
introduces a template class, function, etc.this
is a pointer to the receiver object.throw
is used in exception handling. Note that the default flags we pass to GCC include-fno-exceptions
.try
is used in exception handling. Note that the default flags we pass to GCC include-fno-exceptions
.typedef
defines a type synonym.union
defines an untagged union.using
is a directive related to namespaces.virtual
declares a method which may be overridden.wchar_t
is the wide character type.