LearnFrenzy
Sign in Take a free test

Functions and Default Arguments · Functions MCQ · Question 15

What does [[nodiscard]] do? Answer, explanation & discussion

  • MCQ
  • Easy
  • 0 comments
  • Answer explained
  • Moderated community
Question 15 Back to Exercise

What does [[nodiscard]] on a function do?

  • A Prevents the function from being called
  • B Makes the compiler warn when the caller ignores the return value Correct
  • C Deletes the return value
  • D Makes the function noexcept
Correct Answer: Option B

It is ideal for functions returning error codes or newly created resources that must not be thrown away.

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