Archived

This topic is now archived and is closed to further replies.

laotzu

Problem passing function as parameter

Recommended Posts

I have some code here in a class CWorld, that goes... ... bool CWorld::bInitServer() { ... m_hListenThread = CreateThread(NULL, NULL, (LPTHREAD_START_ROUTINE)&vListenThread, NULL, NULL, &m_dwListenThreadID); ... } //Thread to listen for new connections void CWorld::vListenThread() { ... The error I get is that it says ''error C2276: ''&'' : illegal operation on bound member function expression'' on the third parameter of the CreateThread function. As I understood it, the &vListenThread returned the address of that function, which is then casted into a pointer to a THREAD_START_ROUTINE, so I don''t understand what the error is and can''t figure it out. If anyone can help I''d be very appreciative. Thank you, -lao

Share this post


Link to post
Share on other sites
no, the name of the function is the address of the function. "vListenThread". furthermore "CreateThread" does not accept functions of type "__thiscall".

which i guess wouldn''t make it a function, but a method.

To the vast majority of mankind, nothing is more agreeable than to escape the need for mental exertion... To most people, nothing is more troublesome than the effort of thinking.

Share this post


Link to post
Share on other sites