且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

C 中的 const 与 C++ 中的 const

更新时间:2022-04-02 01:59:19

参见规范,在兼容性附录 C.1.6 中:

See the spec, in the compatibility appendix C.1.6:

7.1.6 [另见 3.5]

7.1.6 [see also 3.5]

更改: const 对象必须在 C++ 中初始化,但在 C 中可以保持未初始化

Change: const objects must be initialized in C++ but can be left uninitialized in C

基本原理: 一个 const 对象不能被赋值,所以它必须被初始化以保存一个有用的值.

Rationale: A const object cannot be assigned to so it must be initialized to hold a useful value.

对原始特征的影响:删除语义明确的特征.

转换难度:语义转换.

应用的广泛程度:很少.