C++ Tokens
The smallest individual units in a program are known as tokens. Most of the tokens in C++ are basically similar to C tokens with the exception of som addition and minor modification. C++ has the following tokens:
- Keywords
- Identifiers
- Constants
- Strings
- Operators
Keywords
The keywords specify specific C++ language features. They are reserved words and cannot be used as the variable name or any user-defined elements name. The following table gives the complete set of C++ keywords:
auto | break | case | char | const | continue | default | do |
double | else | enum | extern | float | for | goto | if |
int | long | register | return | short | signed | sizeof | static |
struct | switch | typedef | union | unsigned | void | volatile | while |
bool | const_cast | dynaimc_cast | explicit | export | false | mutable | namespace |
reinterpret_cast | static_cast | true | typeid | typename | using | wchar_t |
Identifiers
Identifiers refer to the names of variables, functions, arrays, classes etc given by the programmer. Each language has its own rules for naming the identifiers. The following rules are common for both C and C++:
- Only alphabets, digits and underscores are valid.
- Cannot start with a digit.
- Identifiers are case sensitive.
- Cannot use a keyword as identifiers.
- Must not contain white spaces.
- First 31 characters are significant.
Constants
Constants refer to fixed values that do not change during the execution of a program. Constants are also called literals. C an C++ both supports several kinds of literal constants. They include integers, characters, floating point numbers and strings. Example:
- 72 //decimal integer
- 72.5 //floating type integer
- 037 //octal integer
- 0X3 //hexadecimal integer
- "C" //string
- 'D' //character
Operator and String will be discussed later in this tutorial.