Facebook Twitter Gplus LinkedIn YouTube Google Maps RSS
Home Technical Why use Polymorphism
formats

Why use Polymorphism

You would use it when you need a class that could be used in different
ways. For instance try creating a ‘Person’ interface and then implement that
interface in a class called ‘Man’ – implement another class the ‘Person’
interface and call this class ‘Women’ – Now both the ‘Man’ & ‘Women’ Classes
derive there members from the Person interface. The ‘Man’ is a ‘Person’ and
the ‘Women’ is a person. If we had created just two classes called ‘Man’ and
‘Women’ then they would have no connection and would also use most of the
same member names, even with the same logic. In a real time application you
would use it exactly the same way – You will need to plan your project with
polymorpism in mind, compare types, do they implement many of the same
features?

 
Tags:
 Share on Facebook Share on Twitter Share on Reddit Share on LinkedIn
No Comments  comments 

Leave a Reply

Your email address will not be published. Required fields are marked *

*

* Copy this password:

* Type or paste password here:

12,873 Spam Comments Blocked so far by Spam Free Wordpress

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

© All rights reserved to Cyberbrutus. 2012
credit

Switch to our mobile site