Hi,
I am coding a c++ based simulator, for which i need to implement a message queue.
The structure of the problem is such.
We have a program that contain a "queue" of messagePacket
messagePacket in this case is a pair <int , message>
where message is a structure struct message
The structure of a message is
struct message
{
int id;
int sender;
int recver;
dataPacket data;
};
for generic programming, i want to allow the user to define the DATATYPE of data (dataPacket) generically,
So I wrote
template <class dataObject>
class dataPacket
{
dataObject data;
public:
dataPacket(dataObject inData)
{
data = inData;
}
};
The intention is, that depending on my/users requirement, he can design a dataPacket as say
struct newdata
{
vector <int> array;
};
dataPacket <newdata> myData;
message.data = myData
The problem might be visible that without a definite dataype definition in the definition of message, I cannot define the structure message.
I would like to know if it is possible to have dataPacket <void> data;
in the definition of message structure.
Thanking you in advance,
Regards
Ruturaj