LearnFrenzy
Sign in Take a free test

Operator Overloading · Operator Overloading MCQ · Question 12

What does a defaulted <=> give you? Answer, explanation & discussion

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

A C++20 class declares auto operator<=>(const T&) const = default;. Which operators can now be used?

  • A Only <=>
  • B <, <=, > and >= (and == too, since a defaulted <=> also declares a defaulted ==) Correct
  • C Only == and !=
  • D None without more code
Correct Answer: Option B

Relational operators are rewritten to use <=>; a defaulted <=> also implicitly declares a defaulted ==.

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