CPP Data Abstraction

CPP introduced the features of OOPs Concept, i.e, CPP is an object-oriented programming language which uses classes and objects for computations. However, it is not considered to be truly object-oriented programming language. An object oriented programming is based on seven fundamental principles, including data abstraction. OOPS Data Abstraction feature is used for hiding internal details and showing the functionality only.

Example:

#include <iostream.h>  
using namespace std;  
class Multiply  
{  
private: int a, b, c, d;  
public:  
void mul()  
{  
cout<<"Enter three numbers: \n";  
cin>>a>>b>>c;  
d= a*b*c;  
cout<<"Your answer is: "<<d<<endl;  
}  
};  
int main()  
{  
Multiply m;  
m.mul();  
return 0;  
}

Output

Enter three numbers: 
2     
4   
6  
Your answer is: 48
Please follow and like us:
Content Protection by DMCA.com