Threads in C++ | Sololearn: Learn to code for FREE!


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: And the piece of code in which the error occurs: (The error msg is in there) Thank you in advance :)

4/3/2018 10:08:54 AM


2 Answers

New 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 ...