<s>
The	O
One	B-Language
Definition	I-Language
Rule	I-Language
(	O
ODR	O
)	O
is	O
an	O
important	O
rule	O
of	O
the	O
C++	B-Language
programming	I-Language
language	I-Language
that	O
prescribes	O
that	O
classes/structs	O
and	O
non-inline	O
functions	O
cannot	O
have	O
more	O
than	O
one	O
definition	O
in	O
the	O
entire	O
program	B-Application
and	O
template	B-Application
and	O
types	O
cannot	O
have	O
more	O
than	O
one	O
definition	O
by	O
translation	B-Language
unit	I-Language
.	O
</s>
<s>
It	O
is	O
defined	O
in	O
the	O
ISO	O
C++	B-Language
Standard	O
(	O
ISO/IEC	O
14882	O
)	O
2003	O
,	O
at	O
section	O
3.2	O
.	O
</s>
<s>
In	O
any	O
translation	B-Language
unit	I-Language
,	O
a	O
template	B-Application
,	O
type	O
,	O
function	O
,	O
or	O
object	O
can	O
have	O
no	O
more	O
than	O
one	O
definition	O
.	O
</s>
<s>
In	O
the	O
entire	O
program	B-Application
,	O
an	O
object	O
or	O
non-inline	O
function	O
cannot	O
have	O
more	O
than	O
one	O
definition	O
;	O
if	O
an	O
object	O
or	O
function	O
is	O
used	O
,	O
it	O
must	O
have	O
exactly	O
one	O
definition	O
.	O
</s>
<s>
Some	O
things	O
,	O
like	O
types	O
,	O
templates	B-Application
,	O
and	O
extern	O
inline	O
functions	O
,	O
can	O
be	O
defined	O
in	O
more	O
than	O
one	O
translation	B-Language
unit	I-Language
.	O
</s>
<s>
For	O
a	O
given	O
entity	O
,	O
each	O
definition	O
must	O
have	O
the	O
same	O
sequence	O
of	O
tokens	B-Application
.	O
</s>
<s>
Non-extern	O
objects	O
and	O
functions	O
in	O
different	O
translation	B-Language
units	I-Language
are	O
different	O
entities	O
,	O
even	O
if	O
their	O
names	O
and	O
types	O
are	O
the	O
same	O
.	O
</s>
<s>
Some	O
violations	O
of	O
the	O
ODR	O
must	O
be	O
diagnosed	O
by	O
the	O
compiler	B-Language
.	O
</s>
<s>
Other	O
violations	O
,	O
particularly	O
those	O
that	O
span	O
translation	B-Language
units	I-Language
,	O
are	O
not	O
required	O
to	O
be	O
diagnosed	O
.	O
</s>
<s>
In	O
general	O
,	O
a	O
translation	B-Language
unit	I-Language
shall	O
contain	O
no	O
more	O
than	O
one	O
definition	O
of	O
any	O
class	O
type	O
.	O
</s>
<s>
In	O
this	O
example	O
,	O
two	O
definitions	O
of	O
the	O
class	O
type	O
C	O
occur	O
in	O
the	O
same	O
translation	B-Language
unit	I-Language
.	O
</s>
<s>
This	O
typically	O
occurs	O
if	O
a	O
header	B-Language
file	I-Language
is	O
included	O
twice	O
by	O
the	O
same	O
source	O
file	O
without	O
appropriate	O
header	B-Language
guards	I-Language
.	O
</s>
<s>
Defining	O
an	O
object	O
of	O
type	O
S	O
,	O
a	O
function	O
taking	O
an	O
argument	O
of	O
type	O
S	O
,	O
or	O
using	O
S	O
in	O
a	O
sizeof	B-Language
expression	O
are	O
examples	O
of	O
contexts	O
where	O
S	O
must	O
be	O
complete	O
,	O
and	O
therefore	O
require	O
a	O
definition	O
.	O
</s>
<s>
In	O
certain	O
cases	O
,	O
there	O
can	O
be	O
more	O
than	O
one	O
definition	O
of	O
a	O
type	O
or	O
a	O
template	B-Application
.	O
</s>
<s>
A	O
program	B-Application
consisting	O
of	O
multiple	O
header	B-Language
files	I-Language
and	O
source	O
files	O
will	O
typically	O
have	O
more	O
than	O
one	O
definition	O
of	O
a	O
type	O
,	O
but	O
not	O
more	O
than	O
one	O
definition	O
per	O
translation	B-Language
unit	I-Language
.	O
</s>
<s>
If	O
a	O
program	B-Application
contains	O
more	O
than	O
one	O
definition	O
of	O
a	O
type	O
,	O
then	O
each	O
definition	O
must	O
be	O
equivalent	O
.	O
</s>
<s>
In	O
pre-standard	O
C++	B-Language
,	O
all	O
static	O
data	O
members	O
required	O
a	O
definition	O
outside	O
of	O
their	O
class	O
.	O
</s>
<s>
However	O
,	O
during	O
the	O
C++	B-Language
standardization	O
process	O
it	O
was	O
decided	O
to	O
lift	O
this	O
requirement	O
for	O
static	O
const	O
integral	O
members	O
.	O
</s>
<s>
Nevertheless	O
,	O
the	O
wording	O
of	O
the	O
1998	O
C++	B-Language
standard	O
still	O
required	O
a	O
definition	O
if	O
the	O
member	O
was	O
used	O
in	O
the	O
program	B-Application
.	O
</s>
<s>
This	O
included	O
the	O
member	O
appearing	O
anywhere	O
except	O
as	O
the	O
operand	O
to	O
sizeof	B-Language
or	O
typeid	O
,	O
effectively	O
making	O
the	O
above	O
ill-formed	O
.	O
</s>
<s>
This	O
includes	O
array	B-Data_Structure
bounds	O
,	O
case	O
expressions	O
,	O
static	O
member	O
initializers	O
,	O
and	O
nontype	B-Application
template	I-Application
arguments	I-Application
.	O
</s>
<s>
This	O
requirement	O
was	O
relaxed	O
in	O
a	O
later	O
standard	O
,	O
C++11	B-Language
.	I-Language
</s>
<s>
The	O
acronym	O
"	O
odr	O
"	O
here	O
is	O
short	O
for	O
"	O
One	B-Language
Definition	I-Language
Rule	I-Language
"	O
.	O
</s>
<s>
Under	O
a	O
Linux	O
shell	O
to	O
try	O
out	O
,	O
compile	B-Language
with	O
:	O
</s>
<s>
Under	O
a	O
Windows	O
Visual	O
Studio	O
"	O
Build	O
Tools	O
Command	O
Prompt	O
"	O
,	O
compile	B-Language
with	O
:	O
</s>
<s>
The	O
problem	O
is	O
,	O
that	O
the	O
C++	B-Language
linker	O
has	O
to	O
figure	O
out	O
how	O
to	O
build	O
the	O
virtual	O
method	O
table	O
for	O
the	O
(	O
two	O
different	O
)	O
"	O
CDummy	O
"	O
classes	O
,	O
and	O
that	O
only	O
works	O
if	O
the	O
class	O
names	O
are	O
different	O
.	O
</s>
