我正在用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);
}
但它表示运营商'='没有匹配。即使我使用boost :: bind,我也会收到错误。
答案 0 :(得分:4)
构造函数是显式的,所以你需要
my_ptr = thread_pointer(new boost::thread(&myClass::function2, this));
或
my_ptr.reset(new boost::thread(&myClass::function2, this));
这假设您首先需要一个指针。