Breaking News
Loading...
Thursday, 23 April 2015

Polymorphism intro







Polymorphism:
Polymorphism in general is when a piece of a program is designed to allow multiple different types to be used in it.
The word polymorphism means having many forms.
Polymorphism is a mechanism that allows you to implement a function in different ways.
Polymorphism is of two types:
Static Polymorphism:
Static polymorphism is a use of polymorphism that is determined when the program is constructed (such as the Template system in C++). Once the program is constructed, the choice is made and the type used is known.
Dynamic polymorphism:
Dynamic polymorphism is determined at run time. (Such as a pointer to a base class that allows for descendant class pointers to be passed in. The base class provides the interface and the descendants implement that interface in different ways that are suitable to the specifics of the class.)
Decisions are made during run time that choose which type to pass.
The important distinction is deciding at construction (compile) or run time.
Generally, a well designed static polymorphism performs better than dynamic, so it is to be preferred when the design makes it possible. If the information to make a choice is not available until run time, dynamic is the choice.

Function call binding:
   Connecting a function call to a function body is called binding.When binding is performed before the program is  run (by the compiler and linker), it’s called early binding.xx

Late binding:binding occurs at runtime, based on the type of the object. Late binding is also called dynamic binding or runtime binding. When a language implements late binding, there must be some mechanism to determine the type of the object at runtime and call the appropriate member function.
- See more at: http://labstrikes.blogspot.in/2012/08/adsense-middle-blog-post.html#sthash.gQgSkqx8.dpuf

0 comments:

Post a Comment

 
Toggle Footer