Multiple dispatch

http://en.wikipedia.org/wiki/Multiple_dispatch

In "conventional", i.e. single dispatch, object-oriented programming languages, when you invoke a method ("send a message" in Smalltalk, "call a member function" in C++) one of its arguments is treated specially and used to determine which of the (potentially many) methods of that name is to be applied. In many languages, the "special" argument is indicated syntactically; for example, a number of programming languages put the special argument before a dot in making a method call: special.method(other,arguments,here).

In languages with multiple dispatch, all the arguments are treated symmetrically in the selection of which method to call. Matching recognizes first, second, third, etc. position within the call syntax, but no one argument "owns" the function/method carried out in a particular call.

 

single dispatch中,函数中第一个参数不是平等的。

mutiple dispatch中,所有参数都是平等的。

具体实现可以参加wiki中的c++例子。

原文链接: https://www.cnblogs.com/cute/archive/2011/09/13/2174720.html

欢迎关注

微信关注下方公众号,第一时间获取干货硬货;公众号内回复【pdf】免费获取数百本计算机经典书籍

    Multiple dispatch

原创文章受到原创版权保护。转载请注明出处:https://www.ccppcoding.com/archives/32201

非原创文章文中已经注明原地址,如有侵权,联系删除

关注公众号【高性能架构探索】,第一时间获取最新文章

转载文章受原作者版权保护。转载请注明原作者出处!

(0)
上一篇 2023年2月8日 上午9:27
下一篇 2023年2月8日 上午9:27

相关推荐