What does data abstraction refer to? Please provide real life examples alongwith.
相关问题
- Sorting 3 numbers without branching [closed]
- How to compile C++ code in GDB?
- Why does const allow implicit conversion of refere
- thread_local variables initialization
- What uses more memory in c++? An 2 ints or 2 funct
相关文章
- Class layout in C++: Why are members sometimes ord
- How to mock methods return object with deleted cop
- Which is the best way to multiply a large and spar
- C++ default constructor does not initialize pointe
- Selecting only the first few characters in a strin
- What exactly do pointers store? (C++)
- Converting glm::lookat matrix to quaternion and ba
- What is the correct way to declare and use a FILE
Data Abstraction: It is used to provide the necessary information to the user and hide the unnecessary information from the user. It is called data abstraction. It will hide your business logic from outside the world.
Technical Example:
Console.WriteLine();
Non Technical Example: TV remote, Car Remote.
More Detail: Data Abstraction with real-time example
Simply Data Abstraction is nothing but the hiding unnecessary datails from user. Example:Person simply just wants to make a call, he just select or dial no. and click on call button this info. is enough for him.He dont want to know about how connection is made and whatever process behind making call or how voice is transferred.
Data abstraction seems to be explained as breaking data down as far as you can get it. food would be the abstraction of apple, orange, pizza. animal would be the abstraction of cat, cow, pig. A food object would be something like this pseudo code:
all foods have a name, calorie amount, and a weight. That's pretty abstract.
You could then make objects that inherit, which would be a bit less abstract.
pizza now has toppings, but it inherits name, calories, and weight from food.
basically abstraction has been explained as getting to the lowest level of each item and making classes that extend from them. It makes your code more reusable too... If you've bade your base class of food well enough, and included everything abstract about it anyone working in the food industry could use your class.
It refers to the act of representing essential feature without including the background detail or the explanation
Abstraction has two parts:
For example, if I am designing a program to deal with inventory, I would like to be able to find out how many items of a certain type the system has in stock. From the perspective of the interface system, I don't care if I am getting this information from a database, a csv file, a remote repository via a SOAP interface or punch cards. I just care that I can can say
widget.get_items_in_stock()
and know that it will return an integer.If I later decide that I want to record that number in some other way, the person designing the interface doesn't need to know, care or worry about it as long as
widget
still has theget_items_in_stock()
method. Like wise, the interface doesn't need to care if I subclass the widget class and add aget_square_root_of_items_in_stock()
method. I can pass an instance of the new class to it just as well.So in this example, we've hidden the details of how the data is acquired and decided that anything with a
get_items_in_stock()
method is an instance of the same class (or a subclass thereof) for certain purposes.Abstraction means providing only essential information to the outside world and hiding their background details..examp. In ur Computer u can see only monitor, keyboard nd mouse..u don't know anything about internal wiring this is abstraction.