有一个这样的类
class CCSocketDlg : public CDialog
{
   ...........
};
UINT thread(LPVOID);//定义线程操作启动线程:AfxBeginThread(&thread,0);
如果我把UINT thread(LPVOID);放在CCSocketDlg里面定义就出现这样的错误:
   error C2276: '&' : illegal operation on bound member function expression   没太搞明白为什么会这样

解决方案 »

  1.   

    定义成 static UINT __stdcall 的
      

  2.   

    函数名就是指针,不用加&
      

  3.   

    回复3楼:我加了&也没事啊。我把static UINT __stdcall thread(LPVOID);放在类里面,就报错:
    error C2665: 'AfxBeginThread' : none of the 2 overloads can convert parameter 1 from type 'unsigned int (void *)'看来还是放在外面比较简单方便
      

  4.   


    看来是在程序中调用时出错的,你的参数传递的有问题。
    你在调用时需要加上强制转换thread为(AFX_THREADPROC)thread