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.
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.
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.


Popular posts from this blog

MSMQ error : "A workgroup installation computer does not support the operation."

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

Error : login failed on rabbitmq web-management console