本文内容
返回类型的“const”限定符不起作用
C++ 标准指定忽略函数返回类型的顶级 const(或 volatile)限定。
默认情况下,此警告处于关闭状态。
Visual Studio 17.6 中引入了此警告
以下示例产生了 C5266:
// compile with: /W4 /c
#pragma warning(default : 5266) // enable warning C5266 because it's off by default (or compile with /w45266)
const int f() // warning C5266: 'const' qualifier on return type has no effect
{
return 13;
}