Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- FiveWin 1.9.2 - January 97 - <b>polimorphism</b> the same message applied to different objects http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 Polimorphism               The same message applied to different Objects
--------------------------------------------------------------------------------

  The same message sent to Objects of different Classes, invokes different
  methods.

  Suppose we have a ball and a glass. Then I take a hammer and I hit them:

  My message   -->  HammerHit

  Object Ball  --> start jumping from one place into another.

  Object Glass --> Gets destroyed into a lot of small pieces.

  Now I have a TReport() Object and a TLabel() Object:

  I send them the message :Print()

            oReport:Print()
            oLabel:Print()

  I get different results on my printer!


Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson