# const参数

What may be surprising, is that although the parameter is a const inside the function, the compiler otherwise treats the definition of fcn as if we had defined the parameter as a plain int:

     void fcn(const int i) { /* fcn can read but not write to i */ }
void fcn(int i) { /* ... */ }            // error: redefines fcn(int)


This usage exists to support compatibility with the C language, which makes no distinction between functions taking const or nonconst parameters.

• 广告
• 抄袭
• 版权
• 政治
• 色情
• 无意义
• 其他

120