- Part 1: Variables and Data Types
- Part 2: Arrays
- Part 3: Functions
- Part 4: Conditional Statements
- Part 5: Looping
- Part 6: Pointers
- Part 7: Objects
- Part 8: Complex Data Types
In C, the proceeding programming language to C++, the keyword const was very common. A constant, in programming terminology, is anything that doesn’t change. It is paired with other variable types to keep them for being changed during the runtime of the program.
Hardware and Other Special Values
C++ is a system programming language. This means it can be used to write programs that work with hardware and other low-level functionality on different devices. Frequently, hardware have special needs and values to work with certain parts. Often, constants are used for this purpose.
Constants can also be used for other special values. While defining PI is useful example, other special values that do not change during runtime can also be defined as constants.
The keywords static and const can be combined together to create a shared value that does not change. Like other static entries, it would be shared across all objects. Through applying the const keyword, it also cannot be changed at any point while running.