Monday, 7 August 2017

Basic Concept of Object Oriented Programming in C++

Basic Concept of Object Oriented Programming in C++ :

Object orientated programming – As the call indicates makes use of objects in programming. Object orientated programming ambitions to enforce actual world entities like Inheritance, Polymorphism, Abstraction, Encapsulation etc in programming. The main intention of Object orientated programming is to bind together the data and the functions that operates on them in order that no different part of code can get access to this records besides that function.


Let us try to understand a touch approximately most of these, thru a easy instance. Human Beings are residing bureaucracy, widely labeled into sorts, Male and Female. Right? It’s genuine. Every Human being (Male or Female) has legs, two hands, two eyes, one nose, one heart and so forth. There are body elements which are commonplace for Male and Female, but then there are some precise body parts, found in a Male which aren't found in a Female, and some frame elements found in Female but not in Males.

Human Anatomy is exciting, isn't always it? But let's examine how all that is associated with C++ and OOPS. Here we will attempt to give an explanation for all of the OOPS concepts via this case and later we are able to have the technical definitions for all this.

Definitions Of Object Oriented Programming Concept :

Now, let us talk a number of the primary features of Object Oriented Programming which you will be the usage of in C++.

1.     Objects
2.     Classes
3.     Abstraction
4.     Encapsulation
5.     Inheritance
6.     Overloading
7.     Exception Handling
8.   Message Passing

Objects:

Objects are the main or basic unit of Object orientated programming. They are instances of class, which have statistics participants and uses various member functions to carry out tasks.

Syntax for Objects:

class person
{
    char name[20];
    int id;
public:
    void getdetails(){}
};

int main()
{
   person p1; // Here p1 is a object
}

Object absorb area in memory and feature an associated address with like a record in Pascal or shape or union in C.

When a program is accomplished the objects engage by using sending messages to one another.

Each item consists of data and code to manipulate the data. Objects can engage without having to recognize info of each other data or code, it's far sufficient to understand the kind of message accepted and type of response returned by the objects.

Class:

It is just like structures in C language. Class also can be described as user described data type however it also includes functions in it. So, class is basically a blueprint for object. It claim & defines what statistics variables the object will have and what operations may be done on the class's item.

Syntax for class:

class class_name
{
  private:
     //data members and member functions declarations
  public:
     //data members and member functions declarations
  protected:
     //data members and member functions declarations
};

Class is a user defined data type like structures and unions in C.

By default class variables are private but in case of structure it's miles public. In above example person is a class.

Abstraction:


Abstraction refers to showing best the critical features of the application and hiding the details. In C++, Classes offer strategies to the out of doors international to get right of access & use the data variables, however the variables are hidden from direct get entry to. This may be done get right of entry to specifies.

Encapsulation:


Wrapping up (combing) of data and functions into a single unit is called encapsulation. The records is not accessible to the out of doors world and best those functions which might be wrapping in the class can get access to it. This insulation of the direct get access to by the program is referred to as statistics hiding or information hiding.

Inheritance:


Inheritance is a way to reuse once written code over and over. The class that's inherited is called base calls & the class which inherits is referred to as derived class. So while, a derived class inherits a base class, the derived class can use all the functions which can be defined in base class, hence making code reusable.

Polymorphism:


Polymorphism way potential to take multiple form. An operation can also showcase unique behaviors in extraordinary times. The behavior depends upon the types of data used in the operation.
C++ helps operator overloading and function overloading.
Operator overloading is the manner of creating an operator to showcase exclusive behaviors in one of a kind instances is known as operator overloading.
Function overloading is the usage of a single function call to perform specific sorts of tasks.
S we can say that is function with same name, functioning in different way. Or, it also allows us to redefine a function to provide its new definition. You will learn how to do this in details soon in coming lessons.

Exception Handling:


Exception handling is a feature of Object orientated programming, to handle unresolved exceptions or errors produced at run time.

Message Passing:


Objects communicate with each other by sending and receiving information. A message for an object is a request for execution of a manner and therefore will invoke a function inside the receiving item that generates the favored results. Message passing entails specifying the call of the object, the call of the function and the data to be sent.

Viral Programs

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation.

1 comments:

  1. Thanks for guiding us through this post.Can you write a post about game making in c++ language?
    i recommend you to check keywords before publishing any post using google keyword planner guide

    ReplyDelete