class t
{
public:
vector<shared_ptr<thread> > t1;
public:
t()
{
for (int i = 0; i < 3; iPP)
{
t1.push_back(make_shared<thread>(&t::Func, this)); //(1)
}
}
void Func()
{
cout << " hello world!" << endl;
}
};
Why does it have to be initialized in this way in (1)? if
is not written in this way, his error will be:
t. Error: ISO cPP forbids the use of unqualified or parenthesized addresses of non-static member functions to form pointers to member functions
because it forbids direct conversion of non-static class member functions t::Func
to thread
class pointers,
if so, why do you have to write it this way? People like & (t::Func)
will also report the above error