#include <iostream>
#include <string>
using namespace std;
class Person{
public:
//函数调用重载符()调用,仿函数
void operator()(char* str)
{
cout<<str<<endl;
}
int operator()(int a, int b)
{
return a+b;
}
};
void test1()
{
Person per1;
per1("hello world");//使用起来非常类似函数调用,所以叫仿函数
int a = per1(10,20);
cout<<a<<endl;
cout<<Person()(20,30)<<endl;//可以直接输出匿名函数对象
}
int main()
{
test1();
return 0;
}