Abstraction in C++





  • The mechanism of representing only essential features without showing the unwanted background details is called abstraction.

  • Data abstraction refers to, providing only essential information to the outside world and hiding their background details, i.e., to represent the needed information in program without presenting the details.

Let's talk about real life example:

Abstraction shows only important things to the user and hides the internal details for example when you ride a bike, you only know about how to ride bike but do not know about how it work ? and also you do not know internal functionality of bike.
When you accelerate bike speed get fast, when push break it gets stop, you only know that these things have these functionality but do not know how they perform .

In C++ program if we implement class with private and public members then it is an example of data abstraction.

Example of Abstraction
#include<iostream>  
using namespace std;  
 class Sum  
{ 
// hidden data from outside world 
private: 
int x, y, z;  
public:  
void add()  
{  
cout<<"Enter two numbers: ";  
cin>>x>>y;  
z= x+y;  
cout<<"Sum of two number is: ";
cout<< z<< endl;  
}  
};  
int main()  
{  
Sum sm;  
sm.add();  
return 0;  
}          
OUTPUT:
Enter two numbers:
5
3
Sum of two number is: 8

Next topic is Inheritance





 



Training For College Campus

We offers college campus training for all streams like CS, IT, ECE, Mechanical, Civil etc. on different technologies like
C, C++, Data Structure, Core Java, Advance Java, Struts Framework, Hibernate, Python, Android, Big-Data, Ebedded & Robotics etc.

Please mail your requirement at info@prowessapps.in


Projects For Students

Students can contact us for their projects on different technologies Core Java, Advance Java, Android etc.

Students can mail requirement at info@prowessapps.in


CONTACT DETAILS

info@prowessapps.in
(8AM to 10PM):

+91-9026070669 , +91-9451396824

© 2016, prowessapps.in, All rights reserved