c++ - C++ 中的一个定义规则到底是什么?

标签 c++ definition

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/

相关文章:

c++ - 无法创建简单的 DLL 示例

c++ - 函数模板重载

c++ - 动态加载的 PIC 共享库具有来自 NPIC 依赖项的运行时未解析符号

c++ - 不同类别的 QT 信号和插槽

c++ - 如何编写具有仅 move 属性的函数?

c - C 中暂定定义背后的基本原理是什么?

delphi - Delphi 中定义常量时出错

delphi - 从 Delphi 中的其他单元定义类型

function - R,单独的参数函数,可导出自己的在线帮助

c# - 定义委托(delegate)的两种方式