class t
{public: vector<shared_ptr<thread> > t1;public:
t()
{ for (int i = 0; i < 3; i++)
{
t1.push_back(make_shared<thread>(&t::Func, this)); //(1)
}
} void Func()
{ cout << " hello world!" << endl;
}
};请问为什么在(1)的地方一定要如此初始化呢,
不写成这样他的报错会是:
t。错误:ISO c++禁止使用非限定或圆括号的非静态成员函数的地址来形成成员函数的指针
是因为禁止直接将非静态的类成员函数 t::Func 直接转换到thread类指针么?,
如果是因为这样那为什么一定要这样写呢? 像&(t::Func)也会报上面的错
largeQ
相关分类