Searching for "(ODR)."

Q:

Explain one-definition rule (ODR).

Answer

According to one-definition rule, C++ constructs must be identically defined in every compilation unit they are used in. 


As per ODR, two definitions contained in different source files are called to be identically defined if they token-for-token identical. The tokens should have same meaning in both source files. 


Identically defined doesn’t mean character-by-character equivalence. Two definitions can have different whitespace or comments and yet be identical.

Report Error

View answer Workspace Report Error Discuss

Subject: C++