LearnFrenzy
Sign in Take a free test

Encapsulation · Encapsulation MCQ · Question 19

When is a struct with public data appropriate? Answer, explanation & discussion

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

When is it reasonable to use a struct with all-public data members?

  • A Never
  • B For simple data aggregates with no invariants, such as a Point {x, y} or a configuration record Correct
  • C For bank accounts
  • D Whenever performance matters
Correct Answer: Option B

If any combination of member values is valid, there is nothing to protect.

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