C++ Identifiers and Keywords | Learn C++ Online | Fresh2Refresh.com (2024)

Prev Next

C++ Identifiers and Keywords:

In a program to identify a function, variable, class or any of the other user defined item you use identifiers so, this concept is known as Identifiers. The identifier can be started with a letter ‘A’ to ‘Z’ or ‘a’ to ‘z’ or from underscore (_) which is followed by zero or more letters, underscores and digits (0 to 9). The C++ does not allow punctuation characters such as $, % and @ within identifiers. Some of the valid identifiers are: shyam, _max, j_47, name10.

And invalid identifiers are :

4xyz, x-ray, abc 2.

  • Identifiers are case sensitive because C++ is case sensitive i.e. uppercase letters and lowercase letters are different.
  • You cannot start name of an identifier with a digit whereas underscore can be used as first character while naming identifier.
  • Other special characters are not allowed while naming an identifier.
  • You cannot use keywords as identifier.

Keywords are the reserved identifiers that cannot be used as names for the variables in a program. The keywords cannot be used for:

  • Declaring the class name
  • Declaring the object name
  • Declaring the variable name
  • Declaring the function name
asmelse
Autoenum
Breakextern
Casefloat
Catchfor
Charfriend
Classgoto
Constif
Continueinline
Defaultint
Deletelong
Doublenew
operatorTemplate
privateThis
protectedThrow
publictry
registertypedef
returnunion
shortunsigned
signedvirtual
sizeofvoid
staticvolatile
structwhile
switch

Prev Next

Like it? Please Spread the word!

C++ Identifiers and Keywords | Learn C++ Online | Fresh2Refresh.com (2024)
Top Articles
Latest Posts
Article information

Author: Duncan Muller

Last Updated:

Views: 5916

Rating: 4.9 / 5 (79 voted)

Reviews: 94% of readers found this page helpful

Author information

Name: Duncan Muller

Birthday: 1997-01-13

Address: Apt. 505 914 Phillip Crossroad, O'Konborough, NV 62411

Phone: +8555305800947

Job: Construction Agent

Hobby: Shopping, Table tennis, Snowboarding, Rafting, Motor sports, Homebrewing, Taxidermy

Introduction: My name is Duncan Muller, I am a enchanting, good, gentle, modern, tasty, nice, elegant person who loves writing and wants to share my knowledge and understanding with you.