当前位置: 代码迷 >> 综合 >> void operator()重载
  详细解决方案

void operator()重载

热度:70   发布时间:2024-02-28 21:22:12.0
class task
{
public:void operator()() const{std::cout << "hello"<< std::endl;}
};

其中void operator()()的作用是实现对()的重载,示例:

int main()

{

task f;

f();//调用void operator()()

}

//打印结果:

hello

 

  相关解决方案