Identifiers refers to the names of variables, functions, arrays, classes, etc., created by the programmer. They are the fundamental requirement of any language. Each language has its own rules for naming these identifiers. The following rules are common to both C and C++:
- only alphabetic characters, digits and uderscores are permttied.
- The name cannot start with a digit.
- Uppercase and lowercase letters are distinct.
- A declared keyword cannot be used as a variable name.
A major difference between C and C++ is the limit on the length of a name. While ANSI C recognizes only the first 32 characters in a name, ANSI C++ places no limit on its lenght and, therefore, all the characters in a name are significant.
Care should be exercised while naming a variable which is being shared by more than one file containing C and C++ program. Some operating systems impose a restriction on the length of such a variable name.
Constants refers to fixed values that do not change during the execution of a program
Like C, C++ support several kinds of literal constants.They include integers, characters, floating, point numbers and string. Literal constant do not have memory locations, Examples
123 // decimal integer 12.34 // floating point integer 037 // octal integer 0X2 // hexadecimal integer "c++" // string constant 'A' // character constant L 'ab' // wide-character constant