有两个const类型会发出警告/错误.但是,如果已定义类型typedef,则编译器接受它(Visual Studio 2013和在线编译器C++ shell).
#include <iostream>
typedef const int value_type;
int main()
{
const value_type n = 0; //ok
const const int n2 = 0; //error C4114
return 0;
}
Run Code Online (Sandbox Code Playgroud)
有没有人知道为什么?它是一个const (const int),不同于const const int?