使用函数对象的C ++线程,如何调用多个析构函数,而不是构造函数?
请在下面找到代码片段: class tFunc{ int x; public: tFunc(){ cout<<"Constructed : "<<this<<endl; x = 1; } ~tFunc(){ cout<<"Destroyed : "<<this<<endl; } void operator()(){ x += 10; cout<<"Thread running at : "<<x<<endl; } int getX(){ return x; } }; int main() { tFunc t; thread t1(t); if(t1.joinable()) { cout<<"Thread is joining..."<<endl; t1.join(); } …