Polymorphism
• Polymorphism is a feature of OOP with single
interface and multiple methods.
• It also means “One name and ...
Polymorphism
• It indicates calling one or more functions using
same name.
• It is achieved using overloading of functions...
• Multiple methods imply two or more functions with
the same name but with different signatures.
• For example, we have tw...
• With respect to previous example, whether
we find sum of two integers or two floating
point values it doesn’t matter for...
How can we access the member of class?
• The member of a class can be access through pointer
to the class.
• General synta...
Types of Polymorphism
• Also called as static binding, it
binds an object to a function call
during compilation time.
• Re...
Polymorphism 140527082302-phpapp01
Polymorphism 140527082302-phpapp01
Polymorphism 140527082302-phpapp01
of 9

Polymorphism 140527082302-phpapp01

i thick it help you to understand polymorphism function in oop
Published on: Mar 4, 2016
Published in: Engineering      
Source: www.slideshare.net


Transcripts - Polymorphism 140527082302-phpapp01

  • 1. Polymorphism • Polymorphism is a feature of OOP with single interface and multiple methods. • It also means “One name and multiple forms”. • After the inheritance it is another most important feature of OOP. • It helps us to reduce complexity using a single interface and multiple methods.
  • 2. Polymorphism • It indicates calling one or more functions using same name. • It is achieved using overloading of functions and overloading of operators. • Polymorphism is achieved using overloading of functions using: Multiple methods Single interface
  • 3. • Multiple methods imply two or more functions with the same name but with different signatures. • For example, we have two overloaded add functions as shown below: // adds two integer values add(int a, int b) { int c =a+b; cout<<c<<endl; } // adds two floating values add(float a, float b) { float c =a+b; cout<<c<<endl; } The above two functions are called methods
  • 4. • With respect to previous example, whether we find sum of two integers or two floating point values it doesn’t matter for us. • What is required is “to add two values” • So, it is logical to use add as the function name. We may call two functions as shown below: add(10,20); //Invoke the first function add(1.5,3.5); //Invoke the second add function
  • 5. How can we access the member of class? • The member of a class can be access through pointer to the class. • General syntax; P -> member class; • P is pointer to object. • -> is member access operator. • Member class. It is the member of the object;
  • 6. Types of Polymorphism • Also called as static binding, it binds an object to a function call during compilation time. • Refers to events that occur during compile time. • Execution is much faster. • Not flexible since functions are decided during compilation time. • Achieved using normal function calls, function overloading and operator overloading. • Also called as dynamic binding, it binds an object to a function call during run time. • Refers to events that occur during run time. • Execution is slower. • Very flexible since executable functions are decided during run time. • Achieved using inheritance and virtual functions.

Related Documents