By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,294 Members | 2,645 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,294 IT Pros & Developers. It's quick & easy.

Creating a Thread with param a class

P: n/a
Dim
Hi
i am trying to create a Thread using _beginthread that will access data in a class but i keep getting a C2664: '_beginthread' : cannot convert parameter 1 from 'void (DBLR<T>&)' to 'void (__cdecl *)(void *)' with [ T=Packet *].

Anyone who can help, please do so, its driving me crazy. I know its most probably a type casting problem but i don't know what to do
Thank
/////////////////////////////////////////////////////////////code sampl
void qtest1( DBLR<Packet*>&QQQ
{
//do something using whatever instance of DBLR was passe
int main()
{
DBLR<Packet*> DBL; //DBLR template ini

_beginthread( qtest1,0, &DBL )
_endthread();
Nov 17 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Regardless of what you are passing, the thread function has to be of the
type:
void qtest1(void* param);
You can't "explicity" put your class there.

Instead, pass it as a void* and then cast it back into a pointer to your
class inside the function.
Ex:
void qtest1(void* param)
{
MyClass* myParam = (MyClass*)param;

....
}

int main()
{
MyClass* x = new MyClass();
_beginthread(qtest1,0,x);
...
}

HTH
--
Adam Clauss
ca*****@tamu.edu
"Dim" <an*******@discussions.microsoft.com> wrote in message
news:5C**********************************@microsof t.com...
Hi,
i am trying to create a Thread using _beginthread that will access data in a class but i keep getting a C2664: '_beginthread' : cannot convert
parameter 1 from 'void (DBLR<T>&)' to 'void (__cdecl *)(void *)' with
[ T=Packet *].
Anyone who can help, please do so, its driving me crazy. I know its most probably a type casting problem but i don't know what to do. Thanks
/////////////////////////////////////////////////////////////code sample
void qtest1( DBLR<Packet*>&QQQ)
{
//do something using whatever instance of DBLR was passed
}

int main()
{
DBLR<Packet*> DBL; //DBLR template init

_beginthread( qtest1,0, &DBL );
_endthread();
}

Nov 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.