我有一个套接字换行器,它有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
答案 0 :(得分:0)
不完整的类意味着您已声明Socket
类但未定义它。也许它已被声明,但你从未包含含有该定义的.h
文件。