constant are like variable but the difference between constant and variable is that constant value fixed it can't change in whole program but variable value can change during program.Enumeration Constant
An enumeration data type, data type represents a set of identifiers. Each identifier in this set is an enumeration constant.The value of the enumeration constant is determined as:
- In enumeration constant assigned to the explicit value for set of identifier.
- If no explicit value is assigned, the leftmost constant in the set of receives the value zero (0).
- If in the set of integer identifiers with no explicitly assigned values that is one greater than the value represented by the previous identifier.
When declare const its must have initializes means in left hand contain the name of constant and in right hand side have the value of that constant except those referencing externally defined constants.
If constant is an integer then const object can appear in a constant expression and it is initialized to a constant.The following example:
const int number = 200; int ary[number]; /* allowed in C++*/.
If a global const object have no any explicit storage class then it consider as static const by default.
const int number = 12; static const int number1 = 120; extern const int number2 = 121;
Because its linkage is assumed to be internal, a const object can be more easily defined in header files in C++ than in C.