One definition rule in c++
c++, one-definition-rule
Solution
This doesn't break the rule because you define two different variables. They have the same name, but are declared in different scopes, and so are separate entities. Each has a single definition.
The declaration in the function's scope is said to hide the one in the global namespace. Within the function, the unqualified name `a` refers to the local variable, while the qualified name `::a` refers to the global.
Problem
According to the c++ standard: No translation unit shall contain more than one definition of any variable, function, class type, enumeration type, or template. ``` //--translation_unit.cpp--// int a; void foo() { int a; //Second defention of a. ODR fails. } ``` Can you explain me how ODR does work actually?