OOPS in C++


Oops in c++



OOPS ( Object Oriented Programming ) as the name indicates it uses objects in the programming. The aim of the Object Oriented Programming is to implement the real world entities like inheritance, polymorphism, abstraction, etc in programming. Smalltalk is known as the first object oriented programming language.

  • It gives a clear and well arranged structure of the programs
  • It helps in reusability of a code and resulting in shorter programs and reducing the time
  • It is easy and as well as faster to execute

Features of an Object Oriented Programming Language



Features of oops


  • Class
  • Object
  • Abstraction
  • Inheritance
  • Encapsulation
  • Polymorphism

Class :

    The class is known as the building block of the object oriented programming. It is a collection of similar objects that share common properties and relationship. It is a user- defined datatype which holds its own data members and functions, which can be used by making object of that class. 
    Data members are the data variables and the member functions are the functions which use those variables and together this define the properties and behaviour of the object in a class.


Object :


    An object can be known as a real world entity like a table, chair, pen, etc. An objecct has a state and behaviour. The state means the data and the behaviour means the functionality. When a class is defined, no memory is allocated but when a object for that class is created memory is allocated. All the members of the class can be accessed through object.


Abstraction :


    Abstraction means showing the important information and hiding the details. Data abstraction means that showing only the important information to the user and hiding all the details about the process and how it is implemented.


Inheritance :


    Inheritance is a process in which new class is created from the existing classes. The new class created is known as ' child class ' or 'derieved class ' and the existing class is known as the ' base class ' or ' parent class '. The derieved class now can be said as inherited from the base class. The derieved class can now inherit all the properties of the base class.


Encapsulation :


    In simple terms encapsulation can be defined as wrapping up of data or information. It can also known as binding together of data and functions. Encapsulation also helps in data abstraction or hiding. As encapsulation also hides the data and information.


Polymorphism :

    In simple words, polymorphism can be defined as having many forms of a message or information. The polymorphism occurs when there is hierarchy of classes and they are related to inheritance. Polymorphism means when you call a memeber function then any other functions is executed depending on the type of object that calls the function.


Other related topics

C++ program basics

Datatypes in C++

operators in C++