Topic : Keywords and Identifiers in C++ Programming Language: Identifiers | Rules to Create Identifiers:

C++ Keywords:

Keywords are predefined reserved identifiers that have special meanings. They cannot be used as identifiers in Our program. C++ reserves a set of some keywords for its own use. here is a list of C++ Keywords.

C++ reserve a Number of words for special use, also known as reserved words. in below table there are some keywords, we cannot use any of keyword/reserved words in a program as a variable or identifiers. If we accidentally attempt to use any keywords in a program as a variable/identifiers, the compiler will issue an error.



Keywords Description
asm The asm command allows you to insert assembly language commands directly into your code.
auto The auto keyword directs the compiler to use the initialization expression of a declared variable, or lambda expression parameter, to deduce its type.
bool A variable of bool type can have two values True and false: (Read more...)
break The break statement ends execution of the nearest enclosing loop or conditional statement in which it appears. (Read more...)
case A switch statement allows a variable to be tested for equality against a list of values. Each value is called a case, and the variable being switched on is checked for each case. (Read more...)
catch A program catches an exception with an exception handler at the place in a program where you want to handle the problem. The catch keyword indicates the catching of an exception. (Read more...)
char The char data type is used to represent single characters: (Read more...)
class Class is a blueprint for a data type: its a user-defined data type. (Read more...)
const const keyword is used to declare a constant in c++. (Read more...)
const_cast The const_cast is used to cast away the Constance of variables.
continue continue statement work like break statement but Instead of forcing termination, it forces the next iteration of the loop to take place, skipping any code in between. (Read more...)
default A switch statement can have an optional default case, which must appear at the end of the switch. The default case can be used for performing a task when none of the cases is true. (Read more...)
delete Delete keyword is used delete the dynamically allocated memory. (Read more...)
double A variable with double data type is used to allocate memory for Floating-point Numbers. (Read more...)
do its an do...while loop. this loop test the condition at the bottom of the loop. do...while loop is similar to a while loop, except that a do...while loop is guaranteed to execute at least one time. (Read more...)
dynamic_cast The dynamic_cast operator converts pointers from parent to child types. A bad_cast exception occurs when a dynamic_cast to a reference type fails.
else The if statement has an optional else clause that is executed only if the Boolean expression is false. (Read more...)
enum The keyword enum is used to create Enumeration. with the help of enum we can create a new, very simple type and list all the possible value of that types.
explicit User-defined type conversions can either be explicit (When the Programmer calls for one type to be converted to another, as in a cast or direct initialization). Or Implicit (when the language or Program calls for a different type than the one given by the Programmer.)
export Export is used to mark a template definition exported, which allows the same template to be declared, but not defined, in other translation units.
extern The extern storage class is used to give a reference of a global variable that is visible to All the Program files.
false A variable of bool type can have two values True and false. (Read more...)
float Variable with type float is used to store Real Numbers or floating-point numbers (that include decimal position such as 98.6, 100.002 etc). (Read more...)
for A for loop is a repetition control structure that allows you to efficiently write a loop that needs to execute a specific number of times. (Read more...)
friend A friend function is a function that can access the non-public members of a class, even though the function itself is not a member of the class. (Read more...)
goto The goto statement allows the program’s execution flow to jump to a specified location within the function. (Read more...)
if An if statement consists of a Boolean expression followed by one or more statements. (Read more...)
inline inline keyword is used to create an inline function.C++ inline function is powerful concept that is commonly used with classes.
int int keyword is used to store integer values. Integers are whole numbers having no fractional parts. (Read more...)
long The long int type, which may be written as just long, may occupy more storage than the int type and thus be able to represent a larger range of values. (Read more...)
mutable The mutable specifier applies only to class objects,It allows a member of an object to override const member function.
namespace A namespace is a mechanism for grouping features you want to include in a program. (Read more...)
New new operator is used to allocate Memory dynamically for any data-type. (Read more...)
operator An operator is a symbol that tells the compiler to perform specific mathematical or logical manipulations. (Read more...)
private A private member variable or function cannot be accessed, or even viewed from outside the class. Only the class and friend functions can access private members. By default all the members of a class would be private. (Read more...)
protected A protected member variable or function is very similar to a private member but it provided one additional benefit that they can be accessed in child classes which are called derived classes. (Read more...)
public A public member is accessible from anywhere outside the class but within a program. (Read more...)
register The register storage class is used to define local variables that should be stored in a register instead of RAM.
reinterpret_cast The reinterpret_cast operator is used to convert a pointer to a new designated type.
return return keyword is used to return values from program or function.
short The type short int, which may be written as just short, represents integers that may occupy fewer bytes of memory than the int type. (Read more...)
signed The signed data type, can be int or char. signed data type will be Positive, Negative or zero. (Read more...)
sizeof The sizeof operator is used to computes the amount of memory in bytes. (Read more...)
static Static keyword is used to keep a local variable in existence during the life-time of the program instead of creating and destroying it each time.
static_cast The keyword static_cast performs the narrowing conversion and silences the compiler warning.
struct The struct keyword is exactly like the class keyword, except that the default access to members is public: (Read more...)
switch A switch statement allows a variable to be tested for equality against a list of values. (Read more...)
template Templates enable you to define a family of functions or classes that can operate on different types of information. (Read more...)
this Every object in C++ has access to its own address through an important pointer called this pointer. (Read more...)
throw A program throws an exception when a problem shows up. This is done using a throw keyword. (Read more...)
true A variable of bool type can have two values True and false: (Read more...)
try A try block identifies a block of code for which particular exceptions will be activated. It's followed by one or more catch blocks. (Read more...)
typedef using typedef we can create a new name for an existing type.
typeid The typeid operator returns information about an object’s data type
typename The keyword typename can replace class in a template definition in some C++ compilers.
union A union is similar to a structure; however, it defines a single location that can be given many different field names. (Read more...)
unsigned The unsigned data type, can be int or char. unsigned data type will always Positive or zero. (Read more...)
using this keyword tells the compiler that the subsequent code is making use of names in the specified namespace. (Read more...)
virtual Virtual keyword is used to create virtual function. Virtual function is a function in base class. (Read more...)
void in the absence of any data type, void is used. void do not return any value to program. (Read more...)
volatile The modifier volatile tells the compiler that a variable's value may be changed in ways not explicitly specified by the program.
wchar_t The wchar_t data type is used to represent wide characters. (Read more...)
while its an do...while loop. this loop test the condition at the bottom of the loop. do...while loop is similar to a while loop, except that a do...while loop is guaranteed to execute at least one time. (Read more...)


C++ Identifiers:

A C++ identifiers is a name used to identify a variable, Function, class, module, or any other user-defined item. An identifier starts with a letter A to Z or a to z. an underscore (_) followed by zero or more letters, underscore, and digits (0 to 9).
C++ does not allow punctuation characters such as @, $, and % within identifiers.



C++ is a case-sensitive programming language. Thus, "InfoBrother" and "infobrother" are two different identifiers in C++.


While Mathematicians are content with giving their variables one-letter names like x, Programmers should use longer, more descriptive variable names, such as altitude, sum, User_name are better than the equally permissible a, s and u. A variable's name should be related to its purpose within the program. Good variable names make programs more readable by humans.



  • Rules to create identifiers.

    C++ has strict rules for variable names. We must Know these simple rules before creating any variable in C++ programming.

    » Identifiers must contain at least one character.
    » The first character must be an alphabetic letter (upper or lower case) or the underscore.
    » The remaining character may be alphabetic characters (upper or lower case), the underscore, or a digit.
    » NO other characters (Including spaces) are permitted in identifiers.
    » A reserved word cannot be used as an identifier.
    » Here are some example of acceptable identifiers:



Add , sum , Omar , Move_left , a_001 , totalAge, _temp






I Tried my Best to Provide you complete Information regarding this topic in very easy and conceptual way. but still if you have any Problem to understand this topic, or do you have any Questions, Feel Free to Ask Question. i'll do my best to Provide you what you need.

Sardar Omar.
InfoBrother





WRITE FOR INFOBROTHER

Advertising






Advertisement