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!