Literal constant is simply a value typed into the code. In following example 40 and Cat are the known as a literal constants.
E.g.
nCounter = 40;
strAnimalName = "Cat";
Symbolic constant is represented by a name.Its defined exactly the same way as a variable but the qualifier must start with the keyword const and the variable must be initialized.
E.g.
const int nMaxIterations = 49;
const unsigned long nMaxCharInFile = 123234;
Advantages of using Symbolic Constants:
- The symbolic names make the program more readable.
- It’s easier to change a single symbolic constant value than to find and replace all occurrences of a literal in a code.
No comments:
Post a Comment