...
| Code Block | ||||
|---|---|---|---|---|
| ||||
// a.h
#ifndef A_HEADER_FILE
#define A_HEADER_FILE
namespace {
int v;
}
inline int get_v() { return v; }
#endif // A_HEADER_FILE
// a.cpp
#include "a.h"
void f() {
int i = get_v();
// ...
}
// b.cpp
#include "a.h"
void g() {
int i = get_v();
// ...
} |
See DCL60-CPP. Obey the Oneone-Definition Ruledefinition rule for more information on violations of the one-definition rule.
...
Bibliography
| [ISO/IEC 14882-2014] | Subclause 3.2, "One Definition Rule" |
...