C++ language

Data Abstraction in C++
Previous Home Next

Data abstraction send to, endowing only necessary acquaintance to the outward earth and warming their part information, to describe the requirement details in program without current information. abstraction is the procedure of distinct opinion to exclusive pattern of those opinion that work.

Abstraction pains to Element out knowledge by a general stance, that programmers could work closed to the scale of human opinion, avoidance out of knowledge which data in exercises, but intangible to the subject being processed. there are as well levels of abstraction, and even though the name denotes anything, I do not have a usual example, and I can not consider to a exclusive 1 I am flurried about the definition of abstraction

The similar abstract definition could used as a general interface by a group of objects with several tool and conducts but which provide the similar meaning. The inheritance mechanism in object-oriented programming could used to declare an abstract class as the general interface.

Abstraction is providing a team of essence a denomination and regardful ness that as 1 unit.

Advantage of Data Abstraction :-

Class internals are conserved by careless appropriator-level defect, which may immoral to kingdom of the topics. The class execution can develop extra time in reaction to restitution Importance or flaw legworks without need shift in user-level code.

Data members only in the intrinsically segment of the class, the class former is released to formation shift in the data. the execution shift, only the class code requirements to be look into watch what sway the shift may have. data are commons, then any function that endlong penetration the data members of the old evaluation could broken

 

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;
}
Previous Home Next

Tolal:0 Click:

Show All Comments

Did not find what you were looking for leave your name and message. We will revert within 24 hours
Name:
eMail:
Comment / Feedback: