P
Peter
Section 3.3.1 of new C++ standard provides the following definition of
a declarative region:
"Every name is introduced in some portion of program text called a
declarative region, which is the largest part
of the program in which that name is valid, that is, in which that
name may be used as an unqualified name
to refer to the same entity.". The definition is followed by this
example:
int j = 24;
int main() {
int i = j, j;
j = 42;
}
According to an explanation following the example, the declarative
region of the first j includes the entire example. How does this not
contradict the definition of a declarative region? Obviously, the same
name ("j") can't be used to refer to the same entity in the entire
example, because first j (global) and second j (defined in main after
comma) refer to two distinct variables.
a declarative region:
"Every name is introduced in some portion of program text called a
declarative region, which is the largest part
of the program in which that name is valid, that is, in which that
name may be used as an unqualified name
to refer to the same entity.". The definition is followed by this
example:
int j = 24;
int main() {
int i = j, j;
j = 42;
}
According to an explanation following the example, the declarative
region of the first j includes the entire example. How does this not
contradict the definition of a declarative region? Obviously, the same
name ("j") can't be used to refer to the same entity in the entire
example, because first j (global) and second j (defined in main after
comma) refer to two distinct variables.