假定缺少类型说明符-int 错误。注意 C++ 不支持默认初始化

Error Missing Type specifer - int assumed . Note C++ does not support default init

为了使 User1User2 的两个对象 class User 发送和接收消息,

#include <iostream>


using namespace std;

class reply
{
public:
    User* sender;
 };


class User
{
    BlockingQueue<Message > queue;

public:
    
    void sendMessage()
    {
    };

    void run()
    { //...... 
    }

    


};

Player class 中,我收到一条错误消息,指出 Player* sender 不是 Message class![=19= 的成员]

并且在 Message class 中,我收到此错误:

Severity    Code    Description Project File    Line    Suppression State

    Error   C4430   missing type specifier - int assumed. Note: C++ does not support default-int

你能帮我解决这个问题吗?

必须在Message前加上player的前向声明

class Player; <<<<=====
class Message
{
public:

    Player* sender ;
    std::string text;
};

看这里的解释What are forward declarations in C++?

是的 - 应该是 std::string