C++ Keywords and identifier

  • Post author:
Download PDF
Advertisement

C++ keywords

A keyword is a word in C++ language that has a predefined meaning and purpose. The meaning and purpose of C++ Keywords are defined by the developer of language. It cannot be changed or redefined by the user. C++ Keywords can be used for the same purpose for which it is defined. C++ Keywords also known as reserved words. There are different types of keywords in C++ language. The total number of keywords is 63.

asm auto bool break
case catch char class
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 operator private protected
public register reinterpret_cast return
short signed size-of static
static_cast struct switch template
this throw true try
typedef type-id type-name union
unsigned using virtual void
volatile wchar_t while

C++ identifier

The identifier is the names used to represent variables, constants, types, functions and labels in the program. The identifier is an important feature of all computer languages. A good identifier name should be descriptive but short.

An identifier in C++ may consist of 31 characters. If the name of an identifier is longer than 31 characters, the first 31 characters will be used. The remaining characters will be ignored by the C++ compiler. Some important roles for the identifier name are as followings.

  • The first character must be alphabetic or underscore (_).
  • The identifier name must consist of only alphabetic characters, digits or underscores.
  • The reserved word cannot be used as an identifier name.

Types of Identifiers in C++
Advertisement

C++ provides the following types of identifiers

  1. Standard Identifiers/User Define

A type of identifier that has special meaning in C++ is known as a standard identifier.

C++ cannot use a standard identifier for the original purpose if it is redefined.

Example

c-out and c-in, are examples of standard identifiers. These are the name of the input/output objects defined in standard input/output library iostream.h.

  1. User-defined Identifiers

The type of identifier that is defined by the programmer to access memory location is known as a user-defined identifier. The user-defined identifier is used to store data and program results.

Example

Some examples of user-defined identifiers are b, subjects, and age, etc.

 

C++ define directive

Advertisement

This Post Has 2 Comments

  1. ip login

    It is perfect time to make some plans for the future and
    it’s time to be happy. I have read this post and if I could I
    desire to suggest you some interesting things or advice.
    Maybe you could write next articles referring to this article.
    I desire to read more things about it!

    1. Khizar Abbas

      You must tell us what we have got to improve. And whatever advice you can give you can give us happiness I will try to do something good in it.

Comments are closed.