Creating const variables as symbolic constants makes code more readable because we are avoiding magic numbers. However, const correctness is more than just creating symbolic constants. It is important to understand const in relation to function parameters.
It is important to understand the difference between these different function signatures:
void Foo(int* a); //Pass by pointer void Foo(int& a); //Pass by reference void Foo(int a); //Pass by value void Foo(const int a); //Pass by const value void Foo(const int* a);//Pass by pointer to const void Foo(const int& a);//Pass by reference to const
The default behavior of C and C++ is to pass by value. This means that, when you pass a variable to a function, a copy ...