DEFINITION 1: ABSTRACTION - PRATMG/2143-OOP-Tamang GitHub Wiki

One of the most significant aspects of object-oriented programming in C++ is data abstraction. The term "abstraction" refers to the practice of displaying only the most important information while keeping the intricacies hidden. Data abstraction is the process of exposing only the most important aspects of a dataset to the outside world while concealing the implementation specifics.

Consider the case of a man behind the wheel of a vehicle. The man only knows that pressing the accelerators will increase the car's speed and that applying the brakes will stop it, but he has no idea how the speed is actually increased when the accelerator is pressed, nor does he understand the car's inner mechanism or how the accelerator, brakes, and other controls are implemented. Abstraction is exactly that.

abstraction

#include <iostream>
using namespace std;
  
class implementAbstraction
{
    private:
        int a, b;
  
    public:
      
        // method to set values of 
        // private members
        void set(int x, int y)
        {
            a = x;
            b = y;
        }
          
        void display()
        {
            cout<<"a = " <<a << endl;
            cout<<"b = " << b << endl;
        }
};
  
int main() 
{
    implementAbstraction obj;
    obj.set(10, 20);
    obj.display();
    return 0;
}

My reference:

⚠️ **GitHub.com Fallback** ⚠️