Part three: constants versus macros.

In C++, the qualifier ‘const’ specifies a compile-time constraint that an object or variable cannot be modified. The compiler verifies that the object or variable never changes and stops you when you try to modify it or re-assign it. However, writing ‘const’ correct code is way more challenging than just using the keyword in some lines, and then allowing the compiler to figure out what makes sense. In this two-part guide, you will get some hints on how to use it properly.

#define READ_ONLY_VALUE 5


Part two: constant methods.

In C++, the qualifier ‘const’ specifies a compile-time constraint that an object or variable cannot be modified. The compiler verifies that the object or variable never changes and stops you when you try to modify it or re-assign it. However, writing ‘const’ correct code is way more challenging than just using the keyword in some lines, and then allowing the compiler to figure out what makes sense. In this three-part guide, you will get some hints on how to use it properly.


Part one: constant types.

In C++, the qualifier ‘const’ specifies a compile-time constraint that an object or variable cannot be modified. The compiler verifies that the object or variable never changes and stops you when you try to modify it or re-assign it. However, writing ‘const’ correct code is way more challenging than just using the keyword in some lines, and then allowing the compiler to figure out what makes sense. In this three-part guide, you will get some hints on how to use it properly.

Pablo Correa

I am a C/C++ Software Developer focused on UX and Audio, trying to see the big picture behind my work by looking how it will affect the whole user experience.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store