C++ 中的一个定义规则到底是怎么说的?我能找到的唯一值得信赖的事件是在The C++ Programming Language, 3rd 中。编辑,第 9.2.3 页。除此以外,还有没有官方的规则定义?
最佳答案
真理在标准中(3.2 一个定义规则):
No translation unit shall contain more than one definition of any variable, function, class type, enumeration type or template.
[...]
Every program shall contain exactly one definition of every non-inline function or object that is used in that program; no diagnostic required. The definition can appear explicitly in the program, it can be found in the standard or a user-defined library, or (when appropriate) it is implicitly defined (see 12.1, 12.4 and 12.8). An inline function shall be defined in every translation unit in which it is used.
关于c++ - C++ 中的一个定义规则到底是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4192170/