简体   繁体   中英

C++ standard definition of conflicting declarations

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 .

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM