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

Discussion

typedef's have the advantage that they obey scope rules, that is they can be declared local to a function or a block whereas #define's always have a global effect.

  • A.Yes
  • B.No

Answer: A

Correct answer: Yes

The statement is correct, and it follows from where each is processed. A typedef is a declaration handled by the compiler, so it obeys the ordinary scope rules and one declared inside a function or block is invisible outside it. A #define is handled by the preprocessor, which knows nothing of blocks, so it applies from its definition to the end of the file or until #undef.

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

Post your comment

Please log in or register to post a comment.