0

I think, this question is going to be a duplicate. But after lot of thinking and searching also, I am unable clear this question in mind. Now coming to my question, It will be better if I see clear YES or NO answers to the below question

1) Does abstraction means "Detail / Implementation Hiding" ?

2) Does Encapsulation means "Data hiding" ?

3) Is abstraction achieved through "access specifiers (public, private, protected) " ? If so, then how encapsulation is achieved?

Please go through this link too while answering.

http://www.tutorialspoint.com/cplusplus/cpp_data_abstraction.htm

Thank you..!

  • 1
    Possible duplicate of [difference between abstraction and encapsulation?](http://stackoverflow.com/questions/742341/difference-between-abstraction-and-encapsulation) – cf- Apr 18 '16 at 01:00
  • For what it's worth, I would say yes to 1 and 2, and no to 3. Abstraction means you offer a contract to do a certain thing without specifying how it will be done. Encapsulation hides everything that doesn't need to be publicly seen. Access modifiers are good for encapsulation. Inheritance is good for abstraction (general handling for an `Animal` vs specific handling for a `Cat`, `Dog`, etc.). Steven A Lowe's answer in the duplicate thread I linked explains this rather nicely, I think. – cf- Apr 18 '16 at 01:03
  • Thank you for answering. The theory in that link is spoiling my understanding. Can you please tell me reliability of the page I linked ? Sorry If there is any problem in my reading and understanding skills. And by the way, I am agreeing with your answer. – Bharadwaj Gali Apr 18 '16 at 01:19
  • It looks like the page you linked is attempting to explain interfaces. `Adder` is offering a public interface consisting of `addNum`/`getTotal`; how those work behind-the-scenes is irrelevant to the `Adder`'s caller. Your page seems to be making the point that hiding as much as possible and only offering a public interface is a good idea for abstraction, which I agree with. Data hiding is far more about encapsulation, though. – cf- Apr 18 '16 at 01:26
  • The exact same class is used as an example of encapsulation on the same site, here: http://www.tutorialspoint.com/cplusplus/cpp_data_encapsulation.htm – cf- Apr 18 '16 at 01:26
  • Thank you...! Not only that link but there is no proper differentiation on this basic concept. Most of them are saying access specifiers can achieve abstraction. So, Your answer is very much useful to me. Have a nice time. – Bharadwaj Gali Apr 18 '16 at 05:51

0 Answers0