LearnFrenzy
Sign in Take a free test

Lambda Expressions · Lambda MCQ · Question 6

Do two identical lambdas have the same type? Answer, explanation & discussion

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

Do auto a = []{ return 1; }; and auto b = []{ return 1; }; have the same type?

  • A Yes
  • B No – every lambda expression has its own unique closure type Correct
  • C Only in C++20
  • D Only if declared const
Correct Answer: Option B

That is why you store lambdas in auto, templates or std::function.

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