I am trying to execute function from class in other thread, but I get error: 'CFTP::_getfile': function call missing argument list; use '&CFTP::_getfile' to create a pointer to member
I tried to do what the error says, but it doesn't solve problem, I gain other error. I need to have this function in class, because it has some CFTP variables. How can I solve this problem?
//CFTP.h
class CFTP
{
private:
int private_var1; //I don't know what members this class has. These are just examples
bool private_var2;
public:
char public_var1;
long public_var2;
CFTP(int i, bool b, char c, long l)
{
private_var1 = i;
private_var2 = b;
public_var1 = c;
public_var2 = l;
}
void _getfile()
{
//get the file!
}
voidoperator()() //this is the method that boost will call when the thread starts
{
_getfile();
}
};
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
//main.cpp
#include <boost/thread.hpp>
#include "CFTP.h"
int main()
{
CFTP cftpInstance(1, true, 'c', 100);
boost::thread aThread(cftpInstance); //now, CFTP::operator()() will be called
//wait for the thread
aThread.join();
return 0;
}