How do I use the Const keyword?
Const keyword enables defining of a constant- a variable that cannot be reassigned a new value after initialization. The compiler will catch attempts to modify variables that have been declared const.
Here is the syntax:
const float pi = 3.1415;
const int id = 1111;
The variables pi and id now cannot be modified to have any other values.
C++ FAQ Home