Data Abstraction in C++:-
👉Data Abstraction is a process of providing only the essential details to the outside world and hiding the internal details, i.e., representing only the essential details in the program.
👉Data Abstraction is a programming technique that depends on the separation of the interface and implementation details of the program.
- #include <iostream>
- using namespace std;
- class Sum
- {
- private: int x, y, z; // private variables
- public:
- void add()
- {
- cout<<"Enter two numbers: ";
- cin>>x>>y;
- z= x+y;
- cout<<"Sum of two number is: "<<z<<endl;
- }
- };
- int main()
- {
- Sum sm;
- sm.add();
- return 0;
- }
Output:-
Enter two numbers: 3 6 Sum of two number is: 9