473,397 Members | 1,949 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

benefit data hiding in c++?

we have concept of data hiding in c++..but what is its benefit..
its fine that the other classes cannot access the private members of a class..but wats its use??
Sep 6 '07 #1
2 5364
sicarie
4,677 Expert Mod 4TB
we have concept of data hiding in c++..but what is its benefit..
its fine that the other classes cannot access the private members of a class..but wats its use??
That's exactly its use - to hide stuff.

Okay, let me ask you - have you heard of "re-usable" code? What can be a danger of, say, working for a company that has a code base already, but you are tasked with adding a feature to that codebase. You are given documentation of the codebase, why would data hiding be beneficial in that case?
Sep 6 '07 #2
weaknessforcats
9,208 Expert Mod 8TB
Here's an example: You have a date with three ints. One for monthm day, and year. You have written a lot of code using these three ints and, in fact, the names of these ints are scattered throughout all of the user code ever written using your date.

One day the boss says that you need to implment a CIM date. This one requires a string in the format yyyymmddhhmmss.nnnnnn. It is completely incompatible with three ints.

Because your ints were not hidden, all of your code and all of the user code will need to be fixed, recompiled, retested and re-released. You tell your bass you can't implement the new date. It's too much work.

Shortly thereafter you are fired.
Sep 7 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

11
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...
2
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...
28
by: Act | last post by:
Why is it suggested to not define data members as "protected"? Thanks for help!
8
by: Scott J. McCaughrin | last post by:
The following program compiles fine but elicits this message from the linker: "undefined reference to VarArray::funct" and thus fails. It seems to behave as if the static data-member:...
12
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...
11
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...
2
by: subramanian100in | last post by:
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...
162
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.