Key Takeaways
Get a recap of all the concepts learned in this chapter.
We'll cover the following...
In this chapter, we learned that const for class type parameters should be used with references or pointers to avoid copying and accidentally modifying the original object. We also learned odd behaviors of C++ regarding function overloads or their lack when const is used for the parameters.
-
Use
constfor primitive data-type parameters when we want to show they won’t get modified. -
Use
const&for object-type parameters when we have to avoid copying and modifying them. -
Be aware that
constqualification might be ignored, and when we create two overloads, the compiler will not differentiate them, and the compilation will fail. -
Declarations with non-
constparameters might match definitions withconstparameters. However, don’t rely on this feature because it degrades readability