仿函数简介

 仿函数实质是一个对象类,在类中重载实现一个operator(),这样使用起来类似于一个函数,这个类就叫仿函数类。

例如:

 1 #include <iostream>
 2 using namespace std;
 3 
 4 class print
 5 {
 6 public:
 7     void operator()(char* a)
 8     {
 9         std::cout<< a << endl;
10     }
11 };
12 
13 int _tmain(int argc, _TCHAR* argv[])
14 {
15     char* p = "test functor !";
16     print pShow;
17     pShow(p);
18     getchar();
19     return 0;
20 }
原文地址:https://www.cnblogs.com/tyche116/p/9188185.html