Search⌘ K

Solving Problems With the One Definition Rule

Let's learn about name collisions leading to ambiguity and definition inconsistency.

Phil Karlton 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 a few reasons: they have to be precise, simple, short, and expressive at the same time. That makes them meaningful and allows programmers to understand the concepts behind the raw implementation. C++ and many other languages impose one more requirement: many names must be unique.

This is manifested in a few different ways. A programmer is required to follow the ODRThe One Definition Rule (ODR) in C++ states that a program should have only one definition for a given entity within a particular scope to avoid conflicts and ensure consistency.. This says that in the scope of a single translation unit (a ...