Duplicate const qualifier allowed in C but not in C++?

前端 未结 4 446
不知归路
不知归路 2020-12-03 13:35

Sample code snippet

const const const int x = 10;   
int main()
{}

gets compiled in C but not in C++. Why does it get compiled in C? I thou

4条回答
  •  情歌与酒
    2020-12-03 14:03

    C++ 2003 prohibits it in 7.1.5/1 "... redundant cv-qualifiers are prohibited except when introduced through the use of typedefs or template type arguments ...".

提交回复
热议问题