Question 9
Back to Exercise
Can you declare int& refs[3]; or std::vector<int&>?
- A Yes, both
- B No – references are not objects; use pointers or std::reference_wrapper Correct
- C Only the array
- D Only the vector
Correct Answer: Option B
Containers need assignable objects. std::vector<std::reference_wrapper<int>> is the standard workaround.
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!