Hi,
I'm trying to make a C++ thread example to work with VS 2005 without any luck. My implementation attempts to create a thread within a class. A simplified version is:
Header:
#include
<windows.h> //For multithread support#include
<process.h> //For _beginthreadex() and _endthreadex()#include
<iostream>using
namespace std;class
Receiver{
public
:Receiver();
unsigned __stdcall MyThread1(void * param); unsigned tid1; // thread IDsHANDLE hThread1;
// thread handles};
Source:
#include
"Receiver.h"
Receiver::Receiver()
{
hThread1 = (HANDLE) _beginthreadex(NULL, 0,
MyThread1, (void *) NULL,
0, &tid1);
}
unsigned
__stdcall Receiver::MyThread1(void * param){
for (int i = 0; i < 100; i++)
{
cout << "Hello MyThread1!" << endl;
Sleep(2000);
}
return 0;
}
When compiling I get the following error code: error C3867: 'Receiver::MyThread1': function call missing argument list; use '&Receiver::MyThread1' to create a pointer to member.
And when following the compiler's advice to use &Receiver::MyThread1 i the argiment list, I get the following: error C2664: '_beginthreadex' : cannot convert parameter 3 from 'UINT (__stdcall Receiver::* )(void *)' to 'unsigned int (__stdcall *)(void *)'
Although I've seen other msdn users have similar problems, I've found no match to this.

Problems by using _beginthreadex() in VS 2005
Ahmad Mageed
Thanks for helping me out,
I feel like a real idiot.
NoobestNoob
Thread function must be global or static:
static unsigned __stdcall MyThread1(void * param);