C++ standard definition of conflicting declarations

柔情痞子 提交于 2019-12-12 15:17:39

问题


Where does the standard define what a conflicting declaration is?

For example, if I have, at namespace scope, the following declarations:

extern const int a;
extern int a;

this would be an example of conflicting declarations.


回答1:


According to [dcl.type], the cv-qualifier const is part of the type, therefore const int x; and int x; constitute different declarations of the variable x.

Then we arrive at [over]/1, which states that:

When two or more different declarations are specified for a single name in the same scope, that name is said to be overloaded. By extension, two declarations in the same scope that declare the same name but with different types are called overloaded declarations. Only function and function template declarations can be overloaded; variable and type declarations cannot be overloaded.



来源:https://stackoverflow.com/questions/48355073/c-standard-definition-of-conflicting-declarations

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!