LearnFrenzy
Sign in Take a free test

References: lvalue and rvalue · References MCQ · Question 9

Can you create an array of references? Answer, explanation & discussion

  • MCQ
  • Medium
  • 0 comments
  • Answer explained
  • Moderated community
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!

Post your comment

Comments appear after a quick review by our team.

Search LearnFrenzy

Esc

Quick links