LearnFrenzy
Sign in Take a free test

Encapsulation · Encapsulation MCQ · Question 13

What does a const data member do to assignment? Answer, explanation & discussion

  • MCQ
  • Hard
  • 0 comments
  • Answer explained
  • Moderated community
Question 13 Back to Exercise

A class has a const int id_; member. What happens to its copy assignment operator?

  • A It works normally
  • B The implicit copy assignment is deleted, because id_ cannot be assigned Correct
  • C It assigns only non-const members
  • D It throws an exception
Correct Answer: Option B

Objects can still be copy-constructed but not assigned – a trade-off to consider when using const members for immutability.

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