sf::Packet 定义的运算符<< 是否与 sf::Packet 派生的 class 的 (*this) 一起工作?

Is the operator<< defined by sf::Packet working with (*this) of a sf::Packet derived class?

我得到了一个派生自 sf::Packet 的 class,它在其构造函数中传递了一个引用 iots 类型的 Integer。现在在构造函数中,我尝试将 Integer 添加到 sf::Packet 的数据中,如下所示:

class Packet : public sf::Packet
{
public:
    Packet(sf::Int32 type)
    {
        m_Type = type;
        (*this) << m_Type;
    }

    sf::Int32 m_Type
}

但是,如果我尝试在服务器端使用运算符>>提取该整数,则该整数仍保持其初始化状态。

现在我的问题:在这种情况下,甚至可以将此运算符与 this 指针一起使用吗?

Now my Question: Is it even possible to use this operator with the this pointer in this case?

是的,没关系。看看下面的例子:http://coliru.stacked-crooked.com/a/b8f8d5b45ade0ad8.

您应该能够自行使用调试器验证这一点。

However if I try to extract that Integer on the server side with the operator>>

可能是其他地方出错了