Key Takeaways

Get a recap of all the concepts learned in this chapter.

While declaring local variables const is desirable, let’s avoid declaring member variables as const.

  • const member variables cannot be changed, so a class with const members loses copy assignment and move semantics.
  • Using const_cast might lead to undefined behaviour, so we won’t use it as a workaround in the above mentioned special functions.
  • Whenever we see const members in a class during a code review (or in already checked-in code), remember what we just learned.

Get hands-on with 1400+ tech skills courses.