OOP's Concepts in C++.

There are two common programming methods: procedural programming and object-oriented programming (OOP). So far you have been creating procedural programs.

www.mskuthar.blogspot.com
Concepts of OOPs

Procedural Programming
  • In a procedural program data is typically stored in a collection of variables and there is a set of functions that perform operations on the data. The data and the functions are separate entities. 
  • Usually the variables are passed to the functions that perform the desired operations. As you might imagine, the focus of procedural programming is on creating the functions, or procedures, that operate on the program’s data. 
  • Procedural programming works well. However, as programs become larger and more complex, the separation of a program’s data and the code that operates on the data can lead to problems.

Object Oriented programming
  • The object oriented programming design models the real world well and overcomes the shortcomings of procedural paradigm. It views a problem in terms of objects and thus emphasizes on both procedures as well as data.
  • An object is an entity that combines both data and procedures in a single unit. An object’s data items, also referred to as its attributes, are stored in member variables. The procedures that an object performs are called its member functions. This wrapping of an object’s data and procedures together is called encapsulation.
  • Not only objects encapsulate associated data and procedures, they also permit data hiding. Data hiding refers to an object’s ability to hide its data from code outside the object. Only the object’s member functions can directly access and make changes to the object’s data.
Advantages of Object oriented programming.
  1. Software complexity can be easily managed
  2. Object-oriented systems can be easily upgraded
  3. It is quite easy to partition the work in a project based on object

OOPs (Object Oriented Programming)
  • Object means an object with real words like pen, chair, table etc. 
  • Object-oriented programming is a technique or framework used by classes and objects to construct a program. 
  • For providing some principles it simplifies the software development and maintenance:
  1. Object
  2. Class
  3. Inheritance
  4. Polymorphism
  5. Abstraction
  6. Encapsulation
Object
  • Any entity having condition and behavior is known as an object. For instance: chair, pen, table, keypad, bike, etc. That can be both physical and logical.
Class
  • Collection of objects is called class. 
  • It is a logical entity.
Inheritance
  • If one object acquires all parent object's properties and actions, i.e., known as inheritance. 
  • It gives reusability of code. It's used to achieve polymorphism during runtime.
  • Inheritance is a way to reuse once written code again and again. 
  • The class which is inherited is called the Base class & the class which inherits is called the Derived class. 
  • They are also called parent and child class.
  • So when, a derived class inherits a base class, the derived class can use all the functions which are defined in base class, hence making code reusable.
Polymorphism
  • When one function is carried out in different ways, i.e., called polymorphism. 
  • For instance: to persuade the customer differently, draw something e.g. shape or rectangle etc. 
  • In C++, we use overloading function and overriding function to achieve polymorphism.
Abstraction
  • Abstraction is known as covering internal information and revealing features. 
  • For example: we don't know the internal processing of a phone call.
  • To achieve abstraction we use abstract class and interface in C++.
  • Abstraction refers to displaying only the application's essential features and concealing the information. 
  • In C++, classes can provide methods for accessing and using the data variables to the outside world, keeping the variables secret from direct access, or classes can even declare it available to everyone, or perhaps only to the classes that inherit it. 
  • This can be achieved using Specifiers for Entry.
Encapsulation
  • Binding (or wrapping) code and data into one unit together is known as encapsulation. 
  • For instance: capsule, it is wrapped with various medicines.

Advantage of OOPs over Procedure-oriented programming language
  • OOPs makes development and maintenance easier where as in Procedure-oriented programming language it is not easy to manage if code grows as project size grows.
  • OOPs provide data hiding whereas in Procedure-oriented programming language a global data can be accessed from anywhere.
  • OOPs provide ability to simulate real-world event much more effectively. We can provide the solution of real word problem if we are using the Object-Oriented Programming language.

Post a Comment

Previous Post Next Post