如何获取指针的int值

时间:2014-03-18 03:30:11

标签: c++

我有一个套接字换行器,它有RecvData,返回int

int RecvData(void* buff, int bufferSize){
    return recv(hSocket, reinterpret_cast<char*>(buff), bufferSize, 0);
}

我也有这个WebServer函数ReceiveLine来获取HTTP请求:

static string ReceiveLine()
{
    Socket* sock;
    std::string ret;
    while (1) {
        char r;

        switch(sock->SendData(&r,sizeof(r))) {
        case 0: // not connected anymore;
            return "";
        case -1:
            if (errno == EAGAIN) {
                return ret;
            } else {
                // not connected anymore
                return "";
            }
        }

        ret += r;
        if (r == '\n')  return ret;
    }
    return ret;
}

问题是在switch语句中我有这个错误:

Socket* sock;  pointer to incomplete class type is not allowed

1 个答案:

答案 0 :(得分:0)

不完整的类意味着您已声明Socket类但未定义它。也许它已被声明,但你从未包含含有该定义的.h文件。