473,749 Members | 2,384 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

understanding of data abstraction, information hiding and encapsulation

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(functio ns,
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

Sep 25 '07 #1
2 7639
On 2007-09-25 06:42, su************* *@yahoo.com, India wrote:
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.
Yes.
Information hiding means mentioning the class members(functio ns,
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.
The way I see it information hiding and encapsulation are more or less
the same thing, and it means that the user of the interface does not
know (or at least do not need to know) how the functionality provided by
the interface is implemented.

What this means is that when you have defined the interface and written
the code to support it a user should be able to take the code and start
using it. Later you should be able to completely replace the
implementation with a new one that provide the same interface and the
user should not have to make any changes to his/her code.
Kindly correct me if my understanding is wrong. Wherever I have gone
wrong, please provide an example C++ class so that I can understand.
A good example is the use of inheritance to define an interface and then
allow different implementations in derived classes:

#include <iostream>

class Twice
{
public:
virtual unsigned int twice(unsigned int i) = 0;
};

class ShiftTwice : public Twice
{
public:
unsigned int twice(unsigned int i)
{
return i << 1;
}
};

class MultiplyTwice : public Twice
{
public:
unsigned int twice(unsigned int i)
{
return 2 * i;
}
};

int main()
{
Twice* ss = new ShiftTwice();
Twice* ms = new MultiplyTwice() ;

std::cout << ss->twice(4) << "\n";
std::cout << ms->twice(4) << "\n";

delete ss;
delete ms;
}

Since both ShiftTwice and MultiplyTwice have the same interface they can
be used interchangeably as long as we access them through a pointer (or
reference) to Twice.
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.
I am not sure what you are talking about, perhaps runtime type
information, but that have nothing to do with any of the above.

--
Erik Wikström
Sep 25 '07 #2
On Sep 25, 7:42 am, "subramanian10. ..@yahoo.com, India"
<subramanian10. ..@yahoo.comwro te:
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(functio ns,
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

Sep 25 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
4194
by: Lorenzo Villari | last post by:
I premise I don't know C++ well but... I wondered what is this data hiding thing... I mean, if I can look at the header (and i need it beacuse of the class), then what's hidden? Can someone give me an example of something hidden from the user?
2
2388
by: coolwarrior | last post by:
Hi, 1_I want to know the difference between "data hiding" , "steganography" ,"watermarking" ,"capsulation" related to DSP. 2_There r plenty of informaion about data hiding for images on the web ,but I'm looking for a GOOD keyword for searching "signal/speech data hiding/steganography"...Do u have any suggestion about appropriate keywords or websites? thanQ so much 4 ur care! coOlwarrior4ever
12
2090
by: Alex Hunsley | last post by:
There's no really specific questions in this post, but I'm looking for people's thought on the issues within... The two main versions I've encountered for data pseudo-hiding (encapsulation) in python are: method 1: _X - (single underscore) - just cosmetic, a convention to let someone
2
1441
by: Neo | last post by:
I was written this code; in VS2k5 class Program { private: int a;
63
2677
by: time.swift | last post by:
Coming from a C++ / C# background, the lack of emphasis on private data seems weird to me. I've often found wrapping private data useful to prevent bugs and enforce error checking.. It appears to me (perhaps wrongly) that Python prefers to leave class data public. What is the logic behind that choice? Thanks any insight.
11
5651
by: sofeng | last post by:
I'm not sure if "data hiding" is the correct term, but I'm trying to emulate this object-oriented technique. I know C++ probably provides much more than my example, but I'd just like some feedback to find out if I've done anything wrong. Also, I am working on this for an embedded environment, so if there are great inefficiencies with this code, I'd like to know that also. I realize there is overhead with using an "accessor" function. ...
1
14223
by: subramanian100in | last post by:
I am a beginner in C++. I come across the terms data abstraction and encapsulation in C++. I am unable to understand the definitions. Kindly explain these terms with a simple example in C++ Thanks V.Subramanian
162
10286
by: Sh4wn | last post by:
Hi, first, python is one of my fav languages, and i'll definitely keep developing with it. But, there's 1 one thing what I -really- miss: data hiding. I know member vars are private when you prefix them with 2 underscores, but I hate prefixing my vars, I'd rather add a keyword before it. Python advertises himself as a full OOP language, but why does it miss one of the basic principles of OOP? Will it ever be added to python?
2
2289
by: jitendra kumar rathi | last post by:
" it facilitates the object to hide its implementation and expose only interfaces" this above line is for encapsulation or abstraction??? and how?????? my next question is that- does encapsulation hides abstraction??
0
8996
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8832
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9388
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9333
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9254
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8256
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4608
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3319
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2217
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.