on Leave a Comment

Basic Concepts of Object Oriented Programming

Object oriented programming is a guideline that ensures to program to be developed in more managed way. Object oriented programming removes all flaws that is encountered in procedural oriented programming. OOPs combines data and their related function together to ensure that it is not accessed by outside function. Object oriented programming focuses on data rather than procedure. 

Concepts of Object Oriented Programming

Object

Object is a run time entity. Object represents a real world entity such as place, person, car etc. Object is an instance of a class. Object holds apace in memory.

Syntax of object:

<class_name> <object-name>;

Assume, number is a class. If we write number obj1; in our program, then obj1 is a instance of class number, also known as variable of class number.

Class

In simple words, class is a description of an object. Class contains data and code related to an object.

Syntax of class: 

class <class_name>
{
       public:
       //Instance member functions and variable declarations

       private:
       //Instance member functions and variable declarations

       protected;
       //Instance member functions and variable declarations
};

Encapsulation

Encapsulation is a concept of placing all data and functions into a single unit called class. Encapsulation ensures that data is not accessible to outside function. Only those functions that are placed in class can access that data. The functions that are written inside the class, provides an interface between object's data and program.

Abstraction

Abstraction refers to hiding the background details and explanation of data and represents only essential information. In object oriented programming, class is used to achieve abstraction. A class hold all attributes of an object. These attributes are called data member. These attributes are hidden to outside world. Class uses the concept of data abstraction, so class is also known as Abstract Data Type (ADT).

Inheritance

Inheritance is a process by which new class is created from an existing class. New class acquires the properties of existing class. It provides the concept of hierarchical classification. Inheritance provides the concept of code reusability because we can add some new features to an existing class without modifying it. In inheritance, we derive new class from existing class.

Polymorphism

Polymorphism is the ability to use a function or an operator in many ways. For example, consider a function add, this function add two numbers. If this function can add also three or four number, this means add function is used in many ways, polymorphism is achieved.  

0 comments:

Post a Comment