One Definition Rule

In the following, forming a pointer to S or defining a function taking a reference to S are examples of legal constructs, because they do not require the type of S to be complete.

However, during the C++ standardization process it was decided to lift this requirement for static const integral members.

[4] This included the member appearing anywhere except as the operand to sizeof or typeid, effectively making the above ill-formed.

This includes array bounds, case expressions, static member initializers, and nontype template arguments.

odr.h: main.cpp odr1.cpp odr2.cpp Under a Linux shell to try out, compile with: Under a Windows Visual Studio "Build Tools Command Prompt", compile with: When executed the expected output is: But you very likely get: The problem is, that the C++ linker has to figure out how to build the virtual method table for the (two different) "CDummy" classes, and that only works if the class names are different.