Menu

Object Oriented Programming

  • C++ programming language fully supports object-oriented concepts.
  • The main characteristics of Object-Oriented Programming languages are
    1. Data abstraction
    2. Data Encapsulation
    3. Inheritance
    4. Polymorphism

Data Abstraction

  • Data abstraction means representing the features of a system without delivering or representing the background details.

Example

  • Working on a computer system without including the background details.
  • Working of Motor-vehicle without including the background details.

Data Encapsulation

  • Data encapsulation is also known as data hiding, which means data hides the associated code and protect it from external misuse.
  • Another feature of data encapsulation is the implementation details of the class are kept hidden from the external world.
  • Data encapsulation encapsulates the data and functions into a single unit.

Example

  • suppose you want to find the average of three numbers. The instructions to read these three numbers constitute the data and include functions for inputting the data, processing, and output. The data and functions constitute a single unit called class.

Inheritance

  • Inheritance is the property of inheriting the characteristics from the base class or from the existing class.
  • In object-oriented programming, Inheritance is the concept that the process of creating new classes called derived classes from the existing or base classes.
  • The derived class inherits all the capabilities of the base class.

Example

  • We ourselves are an example of these. Technically we are derived from our parents and they are derived from their grandparents and so on. The derived class is always bigger than the base class.

polymorphism

  • Polymorphism is the property of representing the same thing differently in different conditions.

Example

  • The key of the vehicle is used to lock/unlock the vehicle the same as open the petrol tank. ie, the object key behaves differently in different conditions.