operator()
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
class Foo
{
public:
void operator() ()
{
cout <<"Foo operator"<<endl;
}
int operator() (int val)
{
return val*10;
}
};

Foo f;
f(); // Foo operator
cout<< f(5) <<endl; // 50

Foo是定义了调用操作符()的类,它的对象就相当于函数名,因此operator()取名叫函数对象