Possible Duplicate:
Try to describe polymorphism as easy as you can
How would you define polymorphism
to a CS 101 student? Be as concise as possible (maybe an answer of a couple of lines and not too technical). Thanks
Something that has the ability to change itself much like actors in films they can be either the good guy or the bad guy or even both or none. As non technical as I could get.
To extend my first example: the movie company doesnt need an actor to do a specific role as long as its a role.
In A somewhat more technical manner you tell three people to do a job but don't leave any instructions. Those three people will solve the job three different ways(if the job is unique lol) basically you dont care how it gets done as long as it gets done thats what polymorphism is.
I will dump down some one-liners from the top of my head. I think that various answers are necessarily due since polymorphism serves different purposes, depending on the consumer of the service. From formal to informal:
- Allow a multiplicity of automata to provide different semantics based on a common syntax.
- Allow a multiplicity of agents to provide specific behavior respecting a contract.
- You give a task to some students in a class, each one completes it correctly in its own personal way.
- You don't care who gets the job done or exactly how, as long as it satisfies some general criteria.
Exploiting guaranteed functionality among classes.
精彩评论