'Error Missing Type specifer - int assumed . Note C++ does not support default init
In order to make two objects, User1
and User2
, of a class User
sending and receiving messages,
#include <iostream>
using namespace std;
class reply
{
public:
User* sender;
};
class User
{
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:
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 1:[1]
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
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | pm100 |