functor
494 ワード
functor === function object
c function pointer
functor(args....)
sort(container,functor)
function pointer function object
f , sort , , functor,if..else..... function object 。
Python :
class Accumulator(object):
def __init__(self, n):
self.n = n
def __call__(self, x):
self.n += x
return self.n
>>> a = Accumulator(4)
>>> a(5)
9