1) This is exactly what I'm encountering. I googled for that but none of those posts talked how to do this:
member function B::fb makes a call to _beginthreadex with thread function which is a member function ( A::fa ).
2) It generates error C3867: 'A::fa': function call missing argument list; use '&A::fa' to create a pointer to member.
But I don't know how to add &A:: :(
Please fix it and give me some advices.
#include<windows.h>
#include<process.h>
#include<iostream>
using std::cout;
using std::endl;
#include<vector>
using std::vector;
class A
{
public:
unsigned __stdcall fa(void *param);
};
unsigned __stdcall fa(void *param)
{
cout << (int)param << endl;
_endthreadex(0);
return 0;
}
class B
{
public:
B();
~B();
void fb();
private:
vector<A *> a;
};
B::B()
{
a.push_back(new A());
a.push_back(new A());
}
B::~B()
{
for(int i = 0; i < (int)a.size(); ++i)
delete a[i];
}
void B::fb()
{
int var = 0;
_beginthreadex(NULL, 0, a[0]->fa, (void *)var, 0, NULL);
}
int main()
{
B b;
return 0;
}
3) And please show me how to pass a list of arguments (many values) to _beginthreadex.
I mean:
void B::fb()
{
int var = 0;
_beginthreadex(NULL, 0, a[0]->fa, [b]MANY_VALUES[/b], 0, NULL);
}
Thank you in advance :) .