LearnFrenzy
Sign in Take a free test

Arrays and Vectors · Arrays and Vectors MCQ · Question 17

What is special about std::vector<bool>? Answer, explanation & discussion

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

What is special about std::vector<bool>?

  • A Nothing
  • B It packs values as bits, so operator[] returns a proxy object instead of bool& Correct
  • C It cannot grow
  • D It stores ints
Correct Answer: Option B

The space-saving specialisation means &v[0] is not a bool* and auto x = v[0] is a proxy. Use std::vector<char> or std::bitset when that matters.

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