Polymorphism - Property of Object Oriented Programming - Compile time polymorphism

Q.  Which property of Object Oriented Programming is exhibited by the code:

#include< iostream>
class quest
             {
                public:
            float add( float a, float b)
            {
              cout << “The sum is:”;
               reurn(a+b); }   }
           int add( int a, int b, int c)
           {
  cout << ”The sum is:”;
               return(a+b+c);
             }

          int add( int a, int b=0)
           {
              cout << ”The sum is:”;
              return(a+b);
               }
            };
           int main( )

           {
  quest q
              q. add( 50.5, 48.2)
              q. add( 42, 56, 82)
              q. add( 23)
               return 0;
              }

- Published on 19 Oct 15

a. Compile time polymorphism
b. Run time polymorphism
c. Both
d. none

ANSWER: Compile time polymorphism
 
The property of function overloading is also known as Compile time polymorphism. Here in this code we see how a function is overloaded using different datatype, different number of arguments and default argument. Function overloading is a concept which allows the use of same function name to different functions for performing same or different task in the same class.

Post your comment / Share knowledge


Enter the code shown above:

(Note: If you cannot read the numbers in the above image, reload the page to generate a new one.)