新发现一奇怪语法,求科普!该如何处理
新发现一奇怪语法,求科普!
int = 0,C++还可以这样子写吗?
下面是实现
virtual void SendBuf(const char *,size_t,int = 0);
void SendBuf(const char *buf,size_t len,int f = 0);
int = 0,C++还可以这样子写吗?
下面是实现
void TcpSocket::SendBuf(const char *buf,size_t len,int)
{
if (!Ready() && !Connecting())
{
Handler().LogError(this, "SendBuf", -1, "Attempt to write to a non-ready socket" ); // warning
if (GetSocket() == INVALID_SOCKET)
Handler().LogError(this, "SendBuf", 0, " * GetSocket() == INVALID_SOCKET", LOG_LEVEL_INFO);
if (Connecting())
Handler().LogError(this, "SendBuf", 0, " * Connecting()", LOG_LEVEL_INFO);
if (CloseAndDelete())
Handler().LogError(this, "SendBuf", 0, " * CloseAndDelete()", LOG_LEVEL_INFO);
return;
}
if (!IsConnected())
{
Handler().LogError(this, "SendBuf", -1, "Attempt to write to a non-connected socket, will be sent on connect" ); // warning
Buffer(buf, len);
return;
}
if (m_obuf_top)
{
Buffer(buf, len);
return;
}
int n = TryWrite(buf, len);
if (n >= 0 && n < (int)len)
{
Buffer(buf + n, len - n);
}
// if ( data in buffer || !IsConnected )
// {
// add to buffer
// }
// else
// try_send
// if any data is unsent, buffer it and set m_wfds
// check output buffer set, set/reset m_wfds accordingly
{
bool br;
bool bw;
bool bx;
Handler().Get(GetSocket(), br, bw, bx);
if (m_obuf.size())
Set(br, true);
else
Set(br, false);
}
}
相关解决方案