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/p/2174720.html