Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/159.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 左移0有什么意义?_C++ - Fatal编程技术网

C++ 左移0有什么意义?

C++ 左移0有什么意义?,c++,C++,我目前正试图为一个开源服务器实现一个google验证器,他们有这么一小段代码 if (securityFlags & 0x01) // PIN input { pkt << uint32(0); pkt << uint64(0) << uint64(0); // 16 bytes hash?

我目前正试图为一个开源服务器实现一个google验证器,他们有这么一小段代码

  if (securityFlags & 0x01)               // PIN input
                {
                    pkt << uint32(0);
                    pkt << uint64(0) << uint64(0);      // 16 bytes hash?
                    // This triggers the 2 factor authenticator entry to popup on the client side

                }

                if (securityFlags & 0x02)               // Matrix input
                {
                    pkt << uint8(0);
                    pkt << uint8(0);
                    pkt << uint8(0);
                    pkt << uint8(0);
                    pkt << uint64(0);
                }

                if (securityFlags & 0x04)               // Security token input
                {
                    pkt << uint8(1);
                }
if(securityFlags&0x01)//PIN输入
{

pkt
pkt
可能属于重载
运算符运算符的类类型。我希望我正确理解了您的问题,如果没有,请回滚我的编辑。这些调用有助于编译器了解“请参阅”的哪个重载版本以获取更多信息您是说运算符只是@Datsi当时设置的值吗k:对不起,我不明白你的意思。所以它一直在向数据包的末尾添加0?那么,要知道要附加什么值,你需要知道客户端数据包在这些位置的期望值吗?@Datsik是的,要知道要附加什么值,你需要知道协议。哇,这对运营商来说是个非常糟糕的主意加载。当您已经在执行位操作的低级代码中,位运算符、十六进制文字和固定宽度无符号变量四处浮动时,重载位移位运算符以表示位移位以外的内容正是使代码更容易理解的需要:)@ChristianHackl Maybe I曲解,但我宁愿责备决定将高级代码与低级代码混合的人,而不是实现
ByteBuffer
的人。我认为操作符重载是可以的。如果
append
是公共的,他应该改用它(
pkt.append(0);
)@gurka:当然,我不知道该怪谁,但最终的结果并不好。至少,像
//这样的注释不是位移位,而是调用重载运算符
    ByteBuffer& operator<<(uint8 value)
    {
        append<uint8>(value);
        return *this;
    }