Solving problems with the One Definition Rule
Phil Karlton, Netscape's Principal Curmudgeon and Tech Visionary was right on point, when he said the following:
"There are two hard things in computer science: cache invalidation and naming things."
Names are difficult for several reasons. They must be precise yet simple, brief yet expressive. This not only gives them meaning but also enables programmers to grasp the concepts underlying the raw implementation. C++ and many other languages add another stipulation: most names must be unique.
This requirement manifests in the form of the One Definition Rule (ODR): within the scope of a single translation unit (a single .cpp
file), you are required to define a symbol exactly once, even if the same name (whether for a variable, function, class type, enumeration, concept, or template) is declared multiple times. To clarify, "declaring" introduces the symbol, while "defining" provides all its details, such as...