Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7644673
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T09:44:50+00:00 2026-05-31T09:44:50+00:00

Encapsulation is a technique through which, functions are provided (public) which operate on the

  • 0

Encapsulation is a technique through which, functions are provided (public) which operate on the hidden data (private) and return the results.

Internal data could be implemented in many ways(bcoz its hidden), without effecting the interface.

Does this mean, Encapsulation is same as data hiding ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T09:44:52+00:00Added an answer on May 31, 2026 at 9:44 am

    Using private or protected as encapsulation provides a protective shell but does not hide the implementation completely.

    If you change the private implementation of your class, you still need to rebuild all the classes that use it, which is why people use “pImpl” and similar techniques to totally hide the implementation detail.

    In C, there is no private or protected, but one will often create an implementation on forwardly-declared structs that the user never sees (e.g. FILE *) or even void * pointers that are often typedef’ed to some Handle type.

    I will give a reference to
    Herb Sutter’s blog about using pImpls.

    I would generally say that using encapsulation via private/public is a weak form of abstraction, data hiding is a stronger form of abstraction (if abstraction is a good word for hiding the implementation detail) but terminology has always been one of my weaker points.

    However even if you are going to use pImpl or whatever, you don’t want any class or whatever doing anything you like with your implementation detail. There are normally rules as to what can do what, and that is what the “encapsulation” model really brings.

    Some people think that a friend breaks encapsulation but it can actually enhance it, for example, letting a factory object write to the private members of the class. The factory object is like the builder who is building your house, and you give them the access to put everything in its correct place for you.

    And if you write unit tests (and you should) you can allow your unit tests access to the private members of your class too, to test that you got your implementation right.

    So, encapsulation and data (implementation) hiding are both good things to have and should be used in the appropriate manner. They achieve similar things in assigning the roles but are not exactly the same.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I read (Scott Myers) that inheritance breaks encapsulation. When data/internal methods are private (not
DUPE: Private vs. Public members in practice (how important is encapsulation?) In the course
I don't understand what does the 'return' do in Data Encapsulation. For example, while
It is considered best practice for encapsulation to use private fields with accessors (getters
In Java, it's taught that variables should be kept private to enable better encapsulation,
For good encapsulation, decent Objective-C programmers put their private ivars in a private extension
Even though OOP uses objects and data encapsulation, the code still writes out like
How can inheritance break encapsulation if we only use protected and private access modifiers
I've been learning about encapsulation in AS3 and using get/set functions to make variables
I created the following encapsulation over the SQL Dependency object: public class DependencyTracker {

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.