Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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

In order to make two objects, Player1 and Player2, of a class Player sending and receiving messages, I implemented a blocking queue to synchronize the messages. This is the code I used:

#include <iostream>


using namespace std;

class Msg
{
public:
    Player* sender;
 };

template <typename T>
class BlockingQueue
{
public:
    void push(const T& val)
    {}

    T pop()
    {}

};

class Player
{
    BlockingQueue<Message > queue;

public:
    
    void sendMessage()
    {
    };

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

    


};

In the Player class, I get an error indicating that Player* sender is not a member of the Message class!

And in the Message class, i get this error:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Severity    Code    Description Project File    Line    Suppression State

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

Can you please help me with this?

>Solution :

You have to add a forward declaration of player before Message

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

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

see here for explanation What are forward declarations in C++?

and yes – it should be std::string

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading