Major element of object oriented programming(OOP) in C++

No comments

Major  element of object oriented programming(OOP) :-

              1.       Objects
                    2.       Classes
                    3.       Data Encapsulation and Data Abstraction
                    4.       Inheritance
                    5.       Reliability
                    6.       Polymorphism
                    7.       Dynamic Binding
                    8.       Message Passing


            1. Objects :-   Object is a real entity that can store process and retrieve data. It is an                                                     instance of   a  class.

Example :-  Person,Student,etc.

            2. Classes :Class in the basic construct that includes the variables and functions into a                                            single unit.

Example :-   class student
                                {
                                         private:
                                         int roll;
                                          public:
                                           void setdata ()
                                };

               3. Data Encapsulation and Data Abstraction :-  It is amechanism that associates the code and the data. It manipulates into a single unit(class) and keeps then safe from external encapsulation is supported by a construct called class.

Example :-  class student
                           {
                                       private:
                                       int role;
                                       char * name;
                                    public :
                                        void getdata ();
                                        void showdata ();
                           };

Data and methods are encapsulated in class.

Data Abstraction :-  Data abstraction is the ebility to create user define data type or modeling real world objects using built_in data types and a set of operators.

                  4. Inheritance :  It allows the extension and reuse of existing code with out having to re- write the code. Inheritance involves the creation of new classes from an existing class. New classes are called derived class /new class/child class/ sub-class  and existing class is called base class /old class/parent class/ super class. The derive class inherit the members of base class and also add its own.


         Example:-  class A
                              {
                                         Int x;
                                         Public:
                                          Void display()
                                                 {
                                                       Cout <<x;
                                                 }
                                    };

                              Class B : public A
                                                   {
                                                          Int y;
                                                           Public:
                                                            Void show()
                                                                    {
                                                                         C out <<y;
                                                                      }
                                                         };

                        5. Reliability 

                        6. Polymorphism :-   It allows a single name/operator  to be associated with different operations depending on the type of data passed to it. In C++ it is achieved by function overlapping, operator overlapping and dynamic binding.

Example :-  int sum (int a, int b) {return (a+b);}
                             float sum (float a, float b){ return (a+b);}

The observe two functions used to add two integers and two float. The function will be called depending on the arguments passed to it.

7.       Dynamic Binding :- Binding Refers to the linking of a procedure call to the code to be executed in response to the call is also known as binding.

Dynamic Binding means that the code associated with a given procedure call is not known until the time of the call at run time. A function call associated with a polymorphism references depends on the dynamic type of that reference.

We can define binding in  another way also. In strongly typed programming languages typically , We have to declared variable pre or to there use. This also implies the variables definition where the compiler reserves space for the name of the variable to the type that variable. This binding is true within the space in which  the variable is declared.

                                       If the type T of a variable is explicit associated with its name N by declaration, We say that N is statically bound to T. The association process is called static binding.
                                       If the type T of a variable with name N is implicit associated by its content, We say that N is dynamically bound to T. The association process is called Dynamic Binding.

                  8.  Message Passing :-  At object oriented program consists of a set of objects that communicate each other. The process of programming in a object oriented language.

                                               Objects communicate with one another by sending and receiving information much the same way as people pass message to none another. The concept of message passing makes its easier to talk about building system that directly model or simulate there real world counter parts.
                                              A message for an object is a request for execution of a procedure, and there for invoke a function in the receiving object that generates the deserved result.  Message passing involves specifying the name of the object, the name of the function (Message) and the information to be sent. 

No comments :

Post a Comment

Subscribe

Milan Panda
Admin
About Me | Contact
Copyright 2023-2024 © Programming1011 . 🎀 Developed and Design By- Milan Panda. Happy Holi All Of You 🎀