Even though from the standpoint of the official standard, the code sample is badly outdated and not written in real C++, the scope rules are used correctly in this sample. The class scope is the inner scope relative to the scope where two typedef lines define P and Q. And the inner scope, as always, hides the identical names of the outer scope. Nothing weird here — the statement “Q is no longer a type in this scope” is correct. In this inner scope, P and Q are member instance functions of X.