C++ OOPs


The main thing of C++ programming is to introduce the concept of object-oriented programming to the C language. It is a pattern and provides many concepts such as data binding, inheritance, polymorphism and etc.

 

In this everything is represented as an object is known as an object-oriented programming language.

 

The object in C++ language matches a real-world entity such as a dog, chair, table etc. It is a methodology to design a program using the objects and the classes.

In OOPs, we mainly concentrate on the classes and objects.

There are 6 major concept in OOPs:-

  • Object
  • Class
  • Polymorphism
  • Inheritance
  • Abstraction
  • Encapsulation
C++ oops

C++ Object

Object

The object in C++ language matches a real-world entity. Objects having state and behavior.


Example: Dog having eyes and 4 legs but the behavior is barking.


Class

The class is a blueprint of an object. Collection of objects is known as class. It is a logical entity.

C++ Class and Object

C++ inheritance

Inheritance

Acquire the properties and behavior of parent class to subclass is known as the Inheritance. It provides reusability of code and used to achieve runtime polymorphism.


Example: Teacher is a parent class and students acquires all the properties of the teachers.


Polymorphism

Single action is performed by different ways i.e., known as the polymorphism.

Polymorphism means having many forms.


Example: Ben ten can transform into different ways such as aliens.

c++ polymorphism

c++ abstraction

Abstraction

Hiding the details of the object and showing the functionality is called as an abstraction.


Example: Phone call, we do not know the internal processing.


Encapsulation

Wrapping up of data and code together into a single unit is called encapsulation.

Example: Capsule, it is wrapped with different medicines.

C++ Encapsulation

Advantages of OOPs:

  • It is easily adapted and modified by the programmer.
  • Object-oriented programming languages contain rich libraries of objects. It enables faster development.
  • Objects can also be reused within across applications.
  • It is a clear modular structure for programs.
  • It makes software easier to maintain.



OnlineTpoint is a website that is meant to offer basic knowledge, practice and learning materials. Though all the examples have been tested and verified, we cannot ensure the correctness or completeness of all the information on our website. All contents published on this website are subject to copyright and are owned by OnlineTpoint. By using this website, you agree that you have read and understood our Terms of Use, Cookie Policy and Privacy Policy.