Page 72 - Modular_V1.1_Flipbook
P. 72

Inheritance

                  Similar to genetic inheritance, C++ also provides a feature called inheritance. It is one of the most
                  important features of object-oriented programming that allows a class to acquire or inherits
                  all the properties and behaviors of its parent class. The class which inherits the members of
                  another class is called derived class or sub class. On the other hand, the class whose members
                  are inherited is called base class or super class.
                  Polymorphism

                  The term polymorphism is made up of two words “poly” and “morph” which means many forms.
                  In programming, polymorphism is a feature using which an object behaves differently in different
                  situations. C++ allows you to implement polymorphism in three ways: function overloading,
                  operator overloading and function overriding. Function overloading is the process of creating
                  more than one function with same name but different numbers, type or sequence of parameters.
                  Similarly, operator overloading is the process of using an operator for more than one action.
                  For example, when the + (plus) operator is used with the integer values, then it performs the
                  addition operation and when it is used with the sting values, then it performs the concatenation
                  operation. On the other hand, function overriding means to use the same function with same
                  name, return-type and arguments list in both sub class and super class.
                      Recap



                          Object-oriented programming is a programming paradigm that focuses on objects instead of
                         routines or functions.
                         An object is a real-world entity like car, dog, pencil and computer.
                         A class can be defined as a user defined blueprint or prototype that is used to create objects.
                         Data abstraction refers to a process of hiding the complex or unnecessary data and show only
                         the data essential for the user.
                         Encapsulation refers to a process of binding data and function together into a single unit like
                         a capsule.
                         Inheritance allows a class to acquire or inherit all the properties and behaviors from its parent
                         class.

                         The term polymorphism is made up of two words “poly” and “morph” which means many forms.


                                                         Exercise



                  A.   Tick (3) the correct option.
                       1.  Which of the following is an example of POP language?
                           a.  FORTRAN                                      c.  COBOL

                           b.  ALGOL                                       d.  All of these
                       2.  Which of the following is a principle of OOP language?
                           a.  Data Abstraction                             c.  Procedure

                           b.  Function                                    d.  None of these


                  70      Touchpad MODULAR (Version 1.1)-X
   67   68   69   70   71   72   73   74   75   76   77