Originally I have this code:
class Sender{
public:
void deQRequest(){
//some code
}
private:
std::thread t([this] { this->deQRequest(); });
}
I couldn't compile, got "expected a declaration error", I changed the code to the following:
class Sender{
public:
void deQRequest(){
//some code
}
void startThread(){
t = thread([this] { this->deQRequest(); });
}
private:
std::thread t;
}
it worked.. what's the reason for this?
Aucun commentaire:
Enregistrer un commentaire