Abstraction in c++

Abstraction in c++:

To represent the essential feature without including the background detail. Data abstraction is a programming technique which relies on the separation of implementationand interface. E.g Monitor of Computer, we do not know the internal detail of monitor who its work.
Accessing Labels of Abstraction: –

• Members defined with a public section are accessible to all parts of the program. The data-abstraction view of a type is defined by its public members.
• Members defined with a private section are not accessible to code that uses the class. The private sections hide the implementation from code that uses the type.
Benefits of Abstraction:
There are two important advantages of Data abstraction: –
• Class internals are protect from inadvertent user-level errors, which might corrupt the state of the object.
• The class implementation may be evolve over time in response to changing requirements or bug reports without requiring change in user-level code.


#include <iostream.h>


class abc


public: abc(int i = 0) // constructor


t = i;


void put1(int n)// interface to outside world { t += n;


int put() // interface to outside world


return t;


private: int t; // hidden data from outside world


int main( )


abc a;




cout << “TOtal is ” << a.put() <<endl;



TOtal is 60

Leave a Reply

Your email address will not be published. Required fields are marked *