LearnFrenzy
Sign in Take a free test

Typedef · typedef MCQ · Question 11

Can the same typedef be declared twice? Answer, explanation & discussion

  • MCQ
  • Hard
  • 0 comments
  • Answer explained
  • Moderated community
Question 11 Back to Exercise

Is it valid to write typedef int Id; twice in the same scope?

  • A Never
  • B Yes since C11, provided both name exactly the same type Correct
  • C Only in different files
  • D Only with extern
Correct Answer: Option B

C11 allows a typedef to be redeclared if it denotes the same type, which makes it easier for several headers to provide the same alias. A different type for the same name is still an error.

Discussion & Comments 0

Share your method, a shortcut, or ask about a step you didn't follow.

No comments yet. Be the first to share your solution!

Post your comment

Comments appear after a quick review by our team.

Search LearnFrenzy

Esc

Quick links