本文介绍了冲突声明的C ++标准定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
标准在哪里定义冲突声明?
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;
这将是冲突声明的示例.
推荐答案
根据 [dcl.type] , cv限定符 const
是该类型的一部分,因此const int x;
和int x;
构成了变量x
.
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
.
然后我们到达 [over]/1 ,其中指出:
Then we arrive at [over]/1, which states that:
这篇关于冲突声明的C ++标准定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!