user42768
user42768

Reputation: 1971

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.

Upvotes: 3

Views: 227

Answers (1)

rustyx
rustyx

Reputation: 85541

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.

Upvotes: 1

Related Questions