IntelliSense:没有构造函数的实例" Sock :: Connection :: Connection"匹配参数列表C ++

时间:2013-04-25 01:46:19

标签: c++ winsock

我有这个奇怪的问题,我不知道最新情况......它不会让我在VC ++ 2012中创建一个类。我收到此错误:IntelliSense:没有构造函数的实例“Sock :: Connection :: Connection”匹配参数列表C ++

这是命名空间Sock中的连接类

class Connection
    {
    private:
        const char *host;
        const char *nick;
        LPHOSTENT hostEntry;
        SOCKET sock;
        unsigned short port;
        bool ip;    

        _onrecv onrecv;
        _onconnect onconnect;
    public:
        Connection(const char *_host, unsigned short _port, bool _ip, _onrecv myonrecv = NULL, _onconnect myonconnect = NULL);
        ~Connection();

        bool _connect(int delay_ms);
        int _isconnected(fd_set *rd, fd_set *wr, fd_set *ex);
        void start();       
    };

以下是我试图创建它的方式......但它无法正常工作

#include "sock.h"

void WINAPI HandleConnection(SOCKET sock);
void WINAPI HandleReceive(SOCKET sock, char *buf, int len);

static const char host[] = "127.0.0.1";

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInst, LPSTR lpCmdLine, int nShowCmd)
{
    if( Sock::Initiate() )
    {
        using namespace Sock;
        Connection conn(host, 9001);
    }

    return 0;
}

void WINAPI HandleConnection(SOCKET sock)
{

}

void WINAPI HandleReceive(SOCKET sock, char *buf, int len)
{
}

1 个答案:

答案 0 :(得分:1)

在调用构造函数时,看起来缺少非可选参数_ip