We're looking for a user researcher to understand the needs of developers and designers. Is this you or someone you know? Check out the post: https://mzl.la/2IGzdXS

Abstraction in computer programming is a way to reduce complexity and allow efficient design and implementation in complex software systems. It hides the technical complexity of systems behind simpler APIs.

Advantages of Data Abstraction

  • Helps the user to avoid writing low level code.
  • Avoids code duplication and increases reusability.
  • Can change internal implementation of class independently without affecting the user.
  • Helps to increase security of an application or program as only important details are provided to the user.

Example

#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;
}

Learn more

General knowledge

Document Tags and Contributors

Last updated by: chrisdavidmills,