LearnFrenzy
Sign in Take a free test

Complicated Declarations · Complicated Declarations MCQ · Question 6

Declare a function returning a function pointer Answer, explanation & discussion

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

Which declares get as a function taking an int and returning a pointer to a function (void) returning int?

  • A int (*get)(int)(void);
  • B int (*get(int))(void); Correct
  • C int *get(int)(void);
  • D int get(int)(*)(void);
Correct Answer: Option B

get(int) is the function; * makes its result a pointer; the outer (void) and int describe the function pointed to. With typedef int (*fn)(void); it becomes fn get(int);.

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