术语“多态性”从何而来?来自?

发布于 2024-08-24 15:15:31 字数 19 浏览 1 评论 0原文

“多态性”一词从何而来?

Where did the term "polymorphism" come from?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

坏尐絯℡ 2024-08-31 15:15:31

它来自希腊词根“poly”(许多)和“morphe”(形式)。多态对象可以采用多种形式(它可以由指向其任何祖先类的指针表示)。多态函数还可以采用多种形式(它可以对实际上不同类型的对象进行操作)。

It comes from the greek roots "poly" (many) and "morphe" (form). A polymorphic object can take on many forms (it can be represented by a pointer to any of its ancestor classes). A polymorphic function can also take on many forms (it can be made to operate on objects that are actually of different types).

风吹雪碎 2024-08-31 15:15:31

多态这个词来自古希腊语。如果某物具有多个“形状/形式”,则它是多晶型的。

The word of Polymorphism comes from ancient greek. Something is polymorph, if it has more than one "shape/form".

悲念泪 2024-08-31 15:15:31

好吧,程序员从生物学中偷走了这个术语。生物学的历史比 OOP 的历史要长得多!

class

看起来像继承层次结构,不是吗?

无论如何,多态性是指同一物种的两个成员可以具有完全不同的物理特征。它看起来像物种形成,但事实并非如此。给出的示例是“正常”捷豹和“深色变形”捷豹

jag
black jag

另一个例子是性别二态性,

class Human
{
    virtual void eat() ;
} ;


class Man : Human
{
    // implementation for how a man eats:
    void eat() override ;
} ;


class Woman : Human
{
    // implementation for how a woman eats:
    void eat() override ;
} ;

Well programmers stole the term from biology. Biology's been around much longer than OOP!

class

Looks like an inheritance hierarchy, doesn't it.

Anyway, polymorphism is when two members of the same species can have completely different physical traits. It looks like speciation, but it isn't. The example given is the "normal" jaguar and the "dark morph" jaguar

jag
black jag

Another example is sexual dimorphism,

class Human
{
    virtual void eat() ;
} ;


class Man : Human
{
    // implementation for how a man eats:
    void eat() override ;
} ;


class Woman : Human
{
    // implementation for how a woman eats:
    void eat() override ;
} ;
女中豪杰 2024-08-31 15:15:31

多态性是一个英语单词,其出现早于其在计算机科学中的使用。它的意思是“呈现不同形式或形状的能力”。 (参考http://en.wiktionary.org/wiki/polymorphism#Etymology

这类似于计算机科学概念,其中一个对象可以被视为具有许多不同的类型。

Polymorphism is an English word that predates its use in computer science. It means "the ability to assume different forms or shapes." (reference http://en.wiktionary.org/wiki/polymorphism#Etymology)

This is analogous to the computer science concept in which an object can be treated as having many different types.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文