Theme images by Storman. Powered by Blogger.

Friday 26 August 2016

C++ Identifiers

C++has strict rules for variable names. A variable name is one example of an identifier.  An identifier is a word used to name things. One of the things an identifier can name is a variable.We will see in later chapters that identifiers name other things such as functions and classes.  Identifiers have the following form:

  • Identifiers must contain at least one character.
  •  The first character must be an alphabetic letter (upper or lower case) or the underscore
               ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_ 
  • The remaining characters (if any) may be alphabetic characters (upper or lower case), the underscore,or a digit
                                    ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_0123456789
  •  No other characters (including spaces) are permitted in identifiers 
  • A reserved word cannot be used as an identifier

Here are some examples of valid and invalid identifiers:

  • All of the following words are valid identifiers and so qualify as variable names:
    x,x2,total,port_22, and FLAG
C++ Identifiers

This table .C++ reserved words. C++reserves these words for specific purposes in program construction. None of the words in this list may be used as an identifier; thus, you may not use any of these words to name a variable.
 

0 on: "C++ Identifiers"