C++函数返回&&运算符

Arc*_*man 0 c++

我正在浏览一个库,我看到了这个函数:

bool CCAPI::IsConnected() const
{
    int state;
    int res = CCAPIGetConnectionStatus(&state);
    return (res == CCAPI_OK) && state;
}
Run Code Online (Sandbox Code Playgroud)

具体来说,这最后一行是什么意思?在我看来,它正在使用&&运算符返回两个变量.那么这里发生了什么?

Cor*_*mer 5

它将返回单个bool,就像函数说的那样.

运营商&&是合乎逻辑的AND,所以如果res == CCAPI_OKstate != 0那么它将返回true.在这种情况下state,隐式转换bool&&操作.