Question 7
Back to Exercise
m is a std::map<std::string, int> without the key "x". What does int v = m["x"]; do?
- A Throws std::out_of_range
- B Inserts "x" with value 0 and returns 0 Correct
- C Returns garbage
- D Does not compile
Correct Answer: Option B
at() throws instead; find() and contains() look up without inserting.
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!