c++ - 'default' 作为变量名

标签 c++ keyword names

在调试一些代码时,我遇到了一个名为default 的数组。我认为不允许关键字作为变量名。

#include "stdafx.h"
#include <stdio.h>

int main()
{
 int default = 5;
 printf("%d\n", default);
 return 0;
}

现在上面的代码可以在 VS 2008 上顺利编译。'default' 不是关键字吗?为什么它可以作为变量名?副作用?

附注: Infragistics::Win::UltraWinToolbars::ToolbarsCollection 有一个同名的属性!

最佳答案

这是一个known issue在 VC++ 中。基本上是为 C++/CLI 兼容性而设计的。

关于c++ - 'default' 作为变量名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38636372/

相关文章:

python - 在python中查找关键字后的单词

git - Git 是否跟踪版本?

SQL Server 相当于 MySQL 的 EXPLAIN

python - Python 中的 vars() 提供不同的输出

javascript - 调试使用 ES6 模块的 JavaScript 代码

c++ - 为类中的静态变量动态分配内存

android - Mac Eclipse 不解析 NDK 中的 C++ lib 函数

regex - 使用正则表达式验证标题案例全名

C++ 禁止将 `string` 常量转换为 `char*` - Alphabets to Morse converting program

c++ - 求数次幂的递归函数