C++ Constants

Constants are named data-storage locations.  C++ has two types of constants: literal and symbolic. 
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.

Comments

Popular posts from this blog

How to flash CWM Recovery to Samsung Galaxy SL( GT-I9003) using Odin

How to boot Samsung Galaxy SL( GT-I9003) in recovery mode

Exception handling with RestTemplate