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.


#include <iostream>
using namespace std;

class implementAbstraction {

        int a, b;

        // 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);
    return 0;

Learn more

General knowledge

Document Tags and Contributors

Last updated by: mdnwebdocs-bot,