LearnFrenzy
Sign in Take a free test

Encapsulation · Encapsulation MCQ · Question 2

How is data hiding achieved in C++? Answer, explanation & discussion

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

How is data hiding achieved in C++?

  • A With namespaces
  • B By declaring data members private (or protected) Correct
  • C With the static keyword
  • D By using pointers
Correct Answer: Option B

Code outside the class – except friends – cannot name private members.

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