Where in the C++ Standard, does it say that the way to define a variable member of a namespace outside the scope of the namespace, is through the use of the extern
specifier in the declaration of the variable member?
§3.4.1/14 mentions this "en passant":
If a variable member of a namespace is defined outside of the scope of its namespace then any name that appears in the definition of the member (after the declarator-id) is looked up as if the definition of the member occurred in its namespace. [ Example:
namespace N {
int i = 4;
extern int j;
}
int i = 2;
int N::j = i; // N::j == 4
Aucun commentaire:
Enregistrer un commentaire