Consider the following code-snippet
typedef int type;
int main()
{
type *type; // why is it allowed?
type *k ;// which type?
}
I get an error 'k' is not declared in this scope. The compiler parses type *k as multiplication between type* and k. Isn’t this grammar very confusing?
Why is type *type allowed by the C++ Standard? Because the grammar says so? Why?
The question is actually about when exactly a variable name is defined as an identifier, and the language determines that it is right after the point in code where the variable is declared:
There are similar rules in other contexts, and it is just a matter of deciding when identifiers are declared. There are other similar situations, for example in the initialization list of a class:
Or in the scope of the identifiers in the definition of member functions:
As of the rationale for the decision, I cannot tell you but it is consistent and simple.