看完第一章,很多用过的东西看见了别人家的用法,很多不知所以然的东西有了看似恍然大悟却又朦朦胧胧
1、
函数对象 以及巧妙地重载 operator () 来实现一切的调用更像函数调用
函数对象(function object),一种考虑到一个对象可以既包含数据又包含成员函数,那么当定义一个没有数据而只有一个函数的类,然后传递该类的一个实例,就可以实现把函数作为参数传递了,只不过是放入一个对象之内来传递。
//泛型findMax,带有函数对象
//前提:a.size()>0
template
const Object& findMax1(const vector