Identifiers
- Names of things in a C++ program
- A character followed by 0 or more digits or characters
- Characters are a-z,A-Z and _
- You should not start identifiers with a _
- Some good identifiers
- A
- i
- aword
- name
- first_name
- __hpux
- name1
- Some bad identifiers
- There are a number of special words in C++ called Reserved Words.
- These have special meaning to the compiler
- They are listed in appendix A.
- You shouldn't use them as identifiers.
- Your names should
- Have meaning
- Be descriptive
- Not be too long
- Be described.
- Some examples:
- Net_Pay
- username
- FirstName
- I prefer
- Mix upper and lower case.
- Use underscore.
- Use full words when it applies.
- Case matters. The following are all different.
- DataIn
- Datain
- datain
- DATAIN
- Selecting good names for your identifiers is a first step in
writing good self documenting code.