仿函数应用
ckfan
posted @ 2012年10月26日 14:31
in 技术blog
, 1089 阅读
从未接触过仿函数,这个也是这两天才接触的。它主要是一个class重载了“()”来达到目的。直接见代码吧
// 仿函数 struct max_class { public: int operator()(int x, int y) { return x > y ? x : y; } }; template <class T> int get_max(int x, int y, T t) { return t(x,y); } int main() { cout << get_max(11,2,max_class()) << endl; }
2012年10月26日 16:05
这个还有专门的名字啊……
2024年2月24日 14:48
I exactly got what you mean, thanks for posting. And, I am too much happy to find this website on the world of Google