Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

Answer Posted / sankalp

abstraction - it is the act of representing the essential features without including the background details.
classes uses the concept of abstraction.


Benefits of Data Abstraction:
Data abstraction provide two important advantages:

Class internals are protected from inadvertent user-level errors, which might corrupt the state of the object.

The class implementation may evolve over time in response to changing requirements or bug reports without requiring change in user-level code.

By defining data members only in the private section of the class, the class author is free to make changes in the data. If the implementation changes, only the class code needs to be examined to see what affect the change may have. If data are public, then any function that directly accesses the data members of the old representation might be broken.



Data Abstraction Example:

Any C++ program where you implement a class with public and private members is an example of data abstraction. Consider the following example:

#include <iostream>
using namespace std;

class Adder{
public:
// constructor
Adder(int i = 0)
{
total = i;
}
// interface to outside world
void addNum(int number)
{
total += number;
}
// interface to outside world
int getTotal()
{
return total;
};
private:
// hidden data from outside world
int total;
};
int main( )
{
Adder a;

a.addNum(10);
a.addNum(20);
a.addNum(30);

cout << "Total " << a.getTotal() <<endl;
return 0;
}
When the above code is compiled and executed, it produces following result:

Total 60

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Why main function is special in c++?

1076


Which programming language is best?

954


what is COPY CONSTRUCTOR and what is it used for?

1037


What does it mean to declare a member variable as static?

1024


What are friend functions in C++?

1024


Search for: what is pair in c++?

1083


How do I tokenize a string in c++?

1047


Give 10 points of differences between C & C++.

1098


What is the basic structure of a c++ program?

1099


What are its advantages and disadvantages of multiple inheritances (virtual inheritance)?

1163


Can constructor be static in c++?

1069


Why is it necessary to use a reference in the argument to the copy constructor?

1083


To which numbering system can the binary number 1101100100111100 be easily converted to?

1019


What are the 3 levels of programming languages?

1006


What is the difference between #import and #include in c++?

1075