class task { public:void operator()() const{std::cout << "hello"<< std::endl;} };
其中void operator()()的作用是实现对()的重载,示例:
int main()
{
task f;
f();//调用void operator()()
}
//打印结果:
hello
class task { public:void operator()() const{std::cout << "hello"<< std::endl;} };
其中void operator()()的作用是实现对()的重载,示例:
int main()
{
task f;
f();//调用void operator()()
}
//打印结果:
hello