Abstraction

Abstraction :

  • Abstraction means providing only essential information to the outside world and hiding their background details or in-depth details.
  • It is used to separate the interface from implementation of the program/problem
  • It is done at design level.
  • Objects provide the abstraction in C++ programs.
  • Classes are used to define own abstract data types in C++.
  • It increases security.
  • It increases understability of a program.
  • Access Specifiers are used to specifies the access level of the succeeding member definitions :
    1. Public: The members are accessible to every function in the program and can be directly accessed and modified through the object of the class.
    2. Private : Private members are only accessible to the member function of the class, Constructors and friend functions. They cannot be directly modified through object
    3. Protected members : They are like private members but can be inherited to any class. Protected members are accessible to the member functions, Constructor and friend function of itself as well as the constructor ,member and friend function of the derieved class.
Following examples that illustrates the use of objects and classes for abstraction :

OUTPUT :

Leave a Reply

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