C++ Tokens are the tiniest individual units of any program. C++ is the superset of ‘C’ and so most constructs of ‘C’ are permissible in the ‘C++’ with their sense and usage unaffected. So tokens, expressions, and the data types are equal to that of ‘C’.C++ Tokens are the tiniest individual units of any program. C++ is the superset of ‘C’ and so most constructs of ‘C’ are permissible in the ‘C++’ with their sense and usage unaffected. So tokens, expressions, and the data types are equal to that of ‘C’.
Following, given below are the ‘C++’ tokens: (most of the ‘c++’ tokens are basically equal to the ‘C’ tokens, respectively)
- Keywords
- Identifiers
- Constants
- Variables
- Operators
Keywords
These are the reserved words that have a fixed and definite meaning, and their sense cannot be changed or modified. Moreover, the meaning and the working process of these keywords are already known to the compiler. ‘C++’ has more numbers of keywords as compared to ‘C’, and those extra ones are having special working abilities.
There are a total of 32 of these, and these are as follows:
auto const double float int short struct unsigned
break continue elseforlong signed switch void
case default enumgoto register sizeof typedef volatile
char do extern if return static unionwhile
There are additional 30 reserved words that were not in ‘C’, these are therefore new to the ‘C++’, and these are as follows:
asm dynamic_cast namespace reinterpret_cast try
bool explicit new static_cast typeid
catch false operator template typename
class friend privatethis using
const_cast inline public throw virtual
delete mutable protected true wchar_t
Browse more Topics Under Getting Started with C++
- C++ Character Set
- Structure of a C++ Program
- Header Files
- Use of I/O Operators
- Use of endl and setw
- Cascading of I/O Operators
- Compilation in C++
- Error Messages
- Use of Editor
- Basic Commands of Editor
- Linking in C++
- Execution in C++
Identifiers
Identifiers are the names that are given to the different entries just like variables, structures, as well as functions. Also, the names of the identifiers should be unique because these entities are applicable to the implementation of the program.
Identifier naming conventions
Only the alphabetic characters, digits, and underscores are allowed.
The first letter should be an alphabet or an underscore (_).
The identifiers are case-sensitive.
Keywords that are reserved can’t be used as the name of the identifier.
Constants
Constants are similar to a variable, except for one thing, that is their value which never changes during the execution process once defined.
There are two more different ways of defining the constants in ‘C++’. These are as follows:
By the use of the ‘const’ keyword
By the use of the ‘#define’ pre-processor
Declaration of a constant:
const [data_type] [constant_name]=[value];
Variable
A variable is a name that is meaningful. In addition, this name is basically of the data storage location in a computer system’s memory. Similarly, when we use a variable we refer to the memory address of the computer system.
Syntax to declare a variable
[data_type] [variable_name];
Example
#include
int main() {
int a,b;// a and b are integer variable
cout<<” Enter first number :”;
cin>>a;
cout<<” Enter the second number:”;
cin>>b;
int sum;
sum=a+b;
cout<<” Sum is : “<
Operator
‘C++’ operator is a symbol that we use for performing mathematical or logical manipulations.
Arithmetic Operators
Increment and Decrement Operators
Relational Operators
Logical Operators
Bitwise Operators
Assignment Operators
Misc. Operators
FAQ on C++ Tokens
Question 1: What is a token for? Explain the numerous tokens in ‘C++’.
Answer: A token is the tiniest element of a ‘C++’ program that is meaningful to the compiler. Therefore, the ‘C++’ parser identifies these types of tokens: Keywords, Identifiers, Numeric, Boolean, and Pointer Literals.
Question 2: What do we can’t use as an identifier?
Answer: Variable name, function name, structure name, etc. are known as the identifiers. Moreover, space does not come in use in the names.
Question 3: How many varieties of keywords are present there?
Answer: There is a total of 9 types of keywords present: short tail, long tail, short-term, long-term, product defining, and customer defining, geo-targeting, and lastly intent targeting. Further, all of these keywords come with the special strength that makes them multiply our ‘SEO’ efforts when we use them in various situations.
Leave a Reply