On Sep 25, 7:42 am, "subramanian10...@yahoo.com, India"
<subramanian10...@yahoo.comwrote:
Is my following understanding correct ?
Data abstraction means providing the interface - that is, the set of
functions that can be called by the user of a class.
Information hiding means mentioning the class members(functions,
typedefs, data) under the access control labels : public, protected,
private.
Encapsulation means providing the implementation of class member
functions and the implementation is hidden except for the inline
functions which can be present inside the class definition or the
header file which are visible to the user of a class.
Kindly correct me if my understanding is wrong. Wherever I have gone
wrong, please provide an example C++ class so that I can understand.
Also, does the process identification of class, its member functions
and data members, class objects, fall under data abstraction ? If not,
what is it called.
Kindly explain.
Thanks
V.Subramanian
Hi V. Subramanian
I think your understanding about these OO concepts are relatively
correct. My main reference for OOA/D/P is the book by Booch: Object-
Oriented Analysis, Design and Applications, 2nd edition, 1994. Of
course the 3rd edition just published.
1. Abstraction
According to Booch, Abstraction is first and most important concept in
Object Model. Abstraction means focus on more important charactristics
of a concept and ignore less important ones from the point of viewer.
Abstraction focust the outside view of an object/concept. As an
example, consider the vector in standard library. You want to create a
vector with a given size (constructor), enlarge or grow the vector
(push_back), accesing to elements (operator[]) and ... It is less
important how to implements the vector internelly. You may use vector
for years, but you probably don't know how vector is implemented.
2. Encapsulation
Encapsulation is a complementary concept to Abstraction. For effective
use of Abstraction, the implementation of an object should be hidden.
It means encapsulation guarantees abstraction is used only through
operations (or C++ member functions and some related non-member and
friends functions). Consider again the vector. You can use vector
effectivly through its member functions. For using it, you don't have
to know the details of representation (data members) of vector.
Encapsulation focus on the inside view od an object/concept.
3. Information hiding
It is another term for encapsulation. You hide the data or information
from direct manipulation.
For detailed description of these concepts refer to Booch 2nd edition
and The C++ Programming Language 3rd edition by B. Stroustrup.
At last some simple notes:
1. For information hiding you usually put data members under private
and protected access control.
2. Inline has no relation to information hiding.
3. Encapsulation is for code not people.
Regards,
S. Amrollahi