java - Is this Polymorphism metaphor erroneous? -


a metaphor polymorphism mentioned in c++ ground (by herbert schildt) says:

a simple example of polymorphism found in steering wheel of automobile. steering wheel (i.e., interface) same no matter type of actual steering mechanism used. is, steering wheel works same whether car has manual steering, power steering, or rack-and-pinion steering. therefore, once know how operate steering wheel, can drive type of car.

i think previous readings, existence of steering wheel indicates polymorphism , not having same functionality. so, in car, turning wheel left move right.

which 1 more accurate? or confusing duck typing?

it not steering wheel indicates polymorphism, mechanisms behind steering wheel performs steering function signify polymorphism. steering wheel along expected behavior (clockwise means right etc.) metaphor interface.

the steering wheel stands interface while rack , pinion, power , manual equivalent of of possible implementations.


Comments

Popular posts from this blog

IF statement in MySQL trigger -

c++ - What does MSC in "// appease MSC" comments mean? -

javascript - Blogger related post gadget image Resize s72-c [ Need Expert Help ] -