将线程指针绑定到对象时出错 我在C++中做了类似的事情: typedef boost::shared_ptr<boost::thread> thread_pointer; Class myClass { // ...... thread_pointer my_ptr; } myClass::function1 { my_ptr = new boost::thread(&myClass::function2, this); } typedef boost::共享线程指针; 类myClass{ // ...... 线程\u指针我的\u ptr; } myClass::function1{ my_ptr=newboost::thread(&myClass::function2,this); }

将线程指针绑定到对象时出错 我在C++中做了类似的事情: typedef boost::shared_ptr<boost::thread> thread_pointer; Class myClass { // ...... thread_pointer my_ptr; } myClass::function1 { my_ptr = new boost::thread(&myClass::function2, this); } typedef boost::共享线程指针; 类myClass{ // ...... 线程\u指针我的\u ptr; } myClass::function1{ my_ptr=newboost::thread(&myClass::function2,this); },c++,boost,smart-pointers,C++,Boost,Smart Pointers,但它表示运算符“=”不匹配。即使使用boost::bind,也会出现错误 构造函数是显式的,因此需要 my_ptr = thread_pointer(new boost::thread(&myClass::function2, this)); 或 这是假设您首先需要一个指针。构造函数是显式的,因此您需要 my_ptr = thread_pointer(new boost::thread(&myClass::function2, this)); 或 这是假设您首先需要一个指针。

但它表示运算符“=”不匹配。即使使用boost::bind,也会出现错误

构造函数是显式的,因此需要

my_ptr = thread_pointer(new boost::thread(&myClass::function2, this));


这是假设您首先需要一个指针。

构造函数是显式的,因此您需要

my_ptr = thread_pointer(new boost::thread(&myClass::function2, this));


这是假设您首先需要一个指针。

类的多个实例之间共享一个线程,当它被
实例化时,只有其中一个实例的
指针很臭。您确定要共享所有权吗?当使用
这个
指针仅对其中一个实例进行实例化时,在
的多个实例之间共享线程很难闻。你确定你想分享所有权吗?