Why is it that qualified names cannot be re-declared inside functions?
The following code fails to compile (in MSVC2015 and clang)
int i;
namespace N
{
int j;
}
void foo()
{
extern int i;
extern int i;
extern int N::j;
extern int N::j;
}
int main()
{
return 0;
}
However, if we move the two lines extern int N::j;
to just before void foo()
then the code compiles fine. Note that repeated declarations of unqualified names do work.
Aucun commentaire:
Enregistrer un commentaire