Question 19
Back to Exercise
What can a std::function<int(int)> object store?
- A Only plain functions
- B Any callable taking an int and returning something convertible to int: functions, lambdas (with captures), function objects Correct
- C Only lambdas without captures
- D Only member functions
Correct Answer: Option B
It uses type erasure, so different callable types share one variable type – handy for callbacks stored in containers.
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!