Course Content
C++ Introduction
0/1
C++ Variables & Constants
0/1
C++Scope of Variable
0/1
C++ Keywords & Identifiers
0/1
C++ Data Types
0/1
C++ Basic I/O
0/1
C++ Type Conversion
0/1
C++ Operators
0/1
C++ Comments
0/1
C++ If-else
0/1
C++ Ternary Operator
0/1
C++ for Loop
0/1
C++ Ranged for Loop
0/1
C++ while/do-while Loop
0/1
C++ break Statement
0/1
C++ Continue Statement
0/1
C++ switch Statement
0/1
C++ goto Statement
0/1
C++ Functions
0/1
C++ User-defined Functions
0/1
C++ Default Arguments
0/1
C++ Storage Class
0/1
C++ Recursion
0/1
C++ Return by Reference
0/1
C++ Arrays
0/1
C++ Multi-dimentional Arrays
0/1
C++ Arrays & Function
0/1
C++ String
0/1
C++ Structure
0/1
C++ Structure & Functions
0/1
C++ Pointers to Structure
0/1
C++ Pointers
0/1
C++ Void Pointers
0/1
C++ Pointers & Arrays
0/1
C++ Pointers & Functions
0/1
C++ Dynamic Memory Allocation
0/1
C++ OOPs Concepts
0/1
C++ Objects and Class
0/1
C++ Constructors
0/1
C++ Destructors
0/1
C++ Constructor Overloading
0/1
C++ Objects & Function
0/1
C++ Enumeration
0/1
C++ Inheritance
0/1
C++ Inheritance Access Control
0/1
C++ Inheritance Types
0/1
C++ Polymorphism
0/1
C++ Function Overloading
0/1
C++ Function Overriding
0/1
C++ Operator Overloading
0/1
C++ Friend Function
0/1
C++ Virtual Function
0/1
C++ Abstract Class & Pure Virtual Function
0/1
C++ Encapsulation
0/1
C++ Abstraction
0/1
C++ Templates
0/1
C++ Exception Handling
0/1
C++ Multithreading
0/1
C++ Standard Library
0/1
C++ Programming Tutorials
About Lesson

C++ Keywords and Identifiers

In this tutorial, we will learn about keywords. Also, we will learn about identifiers, Rules of Identifiers, how to name them, and some good and bad identifiers name in C++ with the help of examples.


Keywords

1) Keywords are predefined words that have special meanings to the compiler.
2) You can’t use keywords as identidiers as well as variables name in C++ Programs.
3) Keywords are reserved words in C++ liberary and used to perform an internal operations.

For example :-

int dollar;

Here, int is a keyword that indicates dollar is a variable of type integer.


List of Keywords in C++

Here is a list of 32 keywords in C++ language which are also available in C language. (as of C++17)

asm dynamic_cast namespace reinterpret_cast bool
explicit new static_cast false catch
operator template friend private class
this inline public throw const_cast
delete mutable protected true try
typeid typename using virtual wchar_t

Here is a list of other keywords in C++ language. (as of C++17)

alignas decltype and noexcept alignof
template and_eq not not_eq thread_local
nullptr bitand bitor enum or
or_eq typedef export char16_t char32_t
compl volatile constexpr static_assert xor
xor_eq

Note: As C++ is a case sensitive language, all keywords must be written in lowercase.


C++ Identifiers

1) Identifiers are the unique names given to variables, functions, arrays, or other entities by the programmer.
2) Identifiers are the basic requirement of any language.
3) Every language has own rules for naming the identifiers.

For example,

int dollar;
double algBly;

Here, dollar and algBly are identifiers.


Rules for naming identifiers

1) Identifiers can be composed of letters, digits, and the underscore character _.
2) It has no limit on name length.
3) It must begin with either a letter or an underscore.
4) Identifier name cannot start with a digit.
5) In C++, uppercase and lowercase letters are distinct. Therefore, Identifiers are case-sensitive.
6) We cannot use keywords as identifiers.

We can choose any name as an identifier if we follow the above rules. However, we should give meaningful names to the identifier that makes sense.


Examples of good and bad identifiers

Invalid Identifier Bad Identifier Good Identifier
Points table P_table pointsTable
1apple apple_1 apple1
int n_int intNumber

 

Exercise Files
No Attachment Found
No Attachment Found
error: Content is protected !!