Definition:
Abstraction is the concept of exposing only the required essential characteristics and behaviour with respect to a context.Hiding of data is known as data abstraction. In object oriented programming language this is implemented automatically while writing the code in the form of class and object.
Real life example of Abstraction
Example of Abstraction in C++
#include<iostream.h>
#include<conio.h>
class sum
{
// hidden data from outside world
private: int a,b,c;
public:
void add()
{
clrscr();
cout<<"Enter any two numbers: ";
cin>>a>>b;
c=a+b;
cout<<"Sum: "<<c;
}
};
void main()
{
sum s;
s.add();
getch();
}
Output
Enter any two number:
4
5
Sum: 9
Use of Data abstraction :
It can be used to provide security for the data from the unauthorized methods.In C++ language data abstraction can be achieve by using class.
To learn more in detail about C++
Call us @ 98256 18292.
Visit us @tccicomputercoaching.com
No comments:
Post a Comment