开发者

How would you define polymorphism to a CS 101 student? [duplicate]

This qu开发者_Python百科estion already has answers here: Closed 11 years ago.

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:

  1. Allow a multiplicity of automata to provide different semantics based on a common syntax.
  2. Allow a multiplicity of agents to provide specific behavior respecting a contract.
  3. You give a task to some students in a class, each one completes it correctly in its own personal way.
  4. 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜