函数调用缺少参数列表错误(c ++)

时间:2013-06-18 08:55:39

标签: c++

我创建了Windows窗体应用程序,我有这个代码的问题可以有人帮我这个吗?谢谢你的帮助。

    void thListen(void* Args)
        {
            const char* chIp;
            long answer; 
            WSAData wsaData;
            WORD DLLVERSION;
            DLLVERSION = MAKEWORD(2,1);
            answer = WSAStartup(DLLVERSION, &wsaData); // odpowiadanie za uzywanie wersji winsocket
            SOCKADDR_IN addr; // deklarowanie obiekut 
            int addrlen = sizeof(addr);
            SOCKET sListen;
            SOCKET sConnect; 
            sConnect = socket(AF_INET, SOCK_STREAM, NULL);

            chIp = (const char*)(void*) Marshal::StringToHGlobalAnsi(textBox1->Text);

            addr.sin_addr.s_addr = inet_addr(chIp); 
            addr.sin_family = AF_INET;                     
            addr.sin_port = htons(1234);                
            sListen = socket(AF_INET,SOCK_STREAM, NULL);   
            bind(sListen, (SOCKADDR*)&addr, sizeof(addr)); 
            listen(sListen, SOMAXCONN);
            for(;;)
            {
                if(sConnect = accept(sListen, (SOCKADDR*)&addr, &addrlen)) 
                {
                    answer = send(sConnect, "Wiadomosc",10 , NULL); 
                }
            }
            _endthread();
        }
    private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
                 _beginthread(this->thListen, 0, NULL);
             }
    };
}

问题在于this->thListen,错误是Error 1 error C3867: 'WinSockCommunicationApplication::Form1::thListen': function call missing argument list; use '&WinSockCommunicationApplication::Form1::thListen' to create a pointer to member c:\users\bartek\documents\visual studio 2010\projects\winsockcommunicationapplication\winsockcommunicationapplication\Form1.h 139 1 WinSockCommunicationApplication (Visual Studio 2010) 我可以放在那里()我应该做什么?

1 个答案:

答案 0 :(得分:2)

执行它告诉您的操作并替换

_beginthread(this->thListen, 0, NULL);

通过

_beginthread(&WinSockCommunicationApplication::Form1::thListen, 0, NULL);