Threads in C++
Hi, I'm coding some server stuff and I wan't to spawn some threads for handling user connections. But when I try to spawn a thread I get an error. Can somebody tell me what's wrong?? Here's the full Server headers file: https://code.sololearn.com/cwtQmhvgl77u/#cpp And the piece of code in which the error occurs: https://code.sololearn.com/c688xq5wiM54/#cpp (The error msg is in there) Thank you in advance :)
4/3/2018 10:08:54 AML00P3R
2 AnswersNew Answer
Your error message Server.cpp:57:49: error: invalid use of non-static member function ‘void Server::Botnet::listenToInfected(int, sockaddr_in)’ Botnet::listenToInfected is not a static member function so you must pass the instance as 2nd argument e.g. std::thread listenToInfectedThread (&Botnet::listenToInfected, myInstance, server_fd, serv_address);
@Worm this is completly wrong not sure who has voted this up ...