Object Oriented Programming using C++

Introduction

Object refers to the real world entities (also known as Noun). These entities has some functionalities as well as associated attributes. So that Object Oriented Programming is also called real world modeling. Most commonly this programming technique is known as OOP. In this topic we will discuss object oriented programming using c++.

OOP Meaning

The meaning of OOP is Object Oriented Programming, this is most commonly used word. This also provide short way to provide complete sense of Object Oriented Programming technique.

Concepts of OOP

There are aadvance concepts that are associated with Object Oriented Programming.Concepts are also called features of object oriented programming. These features distinguish it from structured programming approach. These all properties made OOP more powerful than traditional programming paradigms.

  • Class

  • Object

  • Inheritance

  • Data Encapsulation

  • Polymorphism

  • Data Abstraction

  • Function Overriding

Class in OOP

Term class in OOP refers to the sketch or blueprint in advance to the object. This Class just provide the list of data members and member function that will be operated by the object created using this class. Class is always created using class keyword in C++. There is no restriction on no of data member or member functions in the defination of class. We can define multiple function/methods in class. A class can be used to created multiple objects as per requirement. This class can also inherit its components (Data memeber/member function) in its derived/child classes.

Syntax of Class in C++

C++ allows follwing way for defiing class in programs.

Class animal {
private:
    int age;
public:
    animal() {
       age = 0;
    }
    int getAge() {
       return age;
    }
}; 

Object in OOP

Inheritance in C++

Encapsulation in C++

Polymorhism in C++

Data Abstraction in C++

Function Overriding

Data Encapsulation vs Data Abstraction

There some differences between data encapsulation and abstraction. Some of these are listed in the follwing table.

Differences
Sr. Data Encapsulation Data Abstraction
1. Encapsulation is process of combining data members and member function into single unit such like a medicine capsule, Data Abstraction refers to the hiding of implementation complexities from outside of the class.
2. This is use to hide class components from outside of class. This is used to hide implementation complexities from outside of the class.
3. Encapsulation separate information of multiple objects created using same class. Abstraction completely hide unwanted/unnecessary data from outside of class scope.
4. Abstraction is achieved using abstract classes. Encapsulation is achieved using access modifiers such as private, public and protected.
5. In abstraction data is prevented from access using abstract classes. In encapsulation data is manipulated using getters and setters.

Object Oriented Programming Languages

There are multiple programming languages that support Object Oriented Paragidm now a days. But we list down some commonly used popular OOP langauges.

  1. C++
  2. Python
  3. C#
  4. Javascript
  5. Java

 

Comments
Login to TRACK of Comments.