-
函数调用运算符()重载:
类定义函数调用运算符():class fctor
{ public:
void operator()(string msg)
{
cout << “from t1” << msg << endl;
}};
main函数:
string str = "i love operator";
thread t1((fctor()),str);
fctor是一个对象,()运算符的重载使我们像调用函数一样调用对象;
如果类定义了调用运算符(),该类称为‘’函数对象“,
- List item