Chapter 4.2
Enum.3: Prefer class enums over “plain” enums
Constants
Constants are great. Types are great. Constants of a specific type are really great. This is why class enums are just fantastic.
Historically, and we hope you no longer feel the need to do this, constants were defined as preprocessor macros. You might have seen something like this in a geometry-related source file:
#define PI 3.1415926535897932385
If you were unfortunate, in another file you might have seen something like this:
#define PI 3.1415926 // fine for float, insufficient for double
Or this:
#define PI 3.1415926535987932385 // mis-transcribed
Or this:
Get Beautiful C++: 30 Core Guidelines for Writing Clean, Safe, and Fast Code now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.