LearnFrenzy
Sign in Take a free test

STL Containers · STL Containers MCQ · Question 12

Requirements for an unordered_map key type Answer, explanation & discussion

  • MCQ
  • Medium
  • 0 comments
  • Answer explained
  • Moderated community
Question 12 Back to Exercise

What does a custom key type need for std::unordered_map?

  • A operator<
  • B A hash function and operator== Correct
  • C A virtual destructor
  • D A default constructor only
Correct Answer: Option B

Ordered containers need operator< (or a comparator) instead.

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