Machine-translated by Google. Questions are authored in English.
Top

Discussion

A compiler that permits a name to be declared in one scope and used in a nested one relies on

  • A.the two scopes being merged into one at compile time
  • B.the name being redeclared in each nested scope
  • C.the linker resolving the reference after compilation
  • D.the scope chain being searched outward from the use

Answer: D

Failing to find the name locally, the compiler searches each enclosing scope in turn. Only when the outermost is exhausted is the name reported as undeclared. The search cost is proportional to the depth of nesting at the point of use.

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.