I recently tried cleaning up my code by separating it into smaller files and separating class member function declarations and definitions to get around issues relating to 'class has not yet been defined' type errors. In the case of one class, I have encountered errors which I assume are related to syntax, but I have spent the last couple of days trying to find a working alternative without luck, so I'm asking for advice here.
In message_related.cpp
Code:
const unsigned int MSG_TURNEND = 1; // A message sent when a turn passes.
const unsigned int MSG_POS = 2; // Increment counter, set boolean to true etc.
const unsigned int MSG_NEG = 3; // Decrement counter, set boolean to false etc.
template <class gen> class msg { // Might have an 'upstream' and 'downstream' version?
unsigned int target; // The ID of the intended recipient of the message.
unsigned int content; // The 'type' of the message - a touch message, a break message etc.
gen ori; // Where to send 'return' messages.
public:
msg(unsigned int dest, unsigned int cont, gen or);
};
In message_related.hpp
Code:
msg <class gen> (unsigned int dest, unsigned int cont, gen or)
{
target = dest;
content = cont;
ori = or;
}
This is the (reduced for posting) setup I have at present, though I have tried others with varying error counts. As far as I can tell the <class gen> in the .hpp seems to be causing a "declaration terminated incorrectly" error, but removing that bit results in the same error message plus a "cannot use template specialisation without specifying specialisation parameter" type error. I have tried using the usual scope resolution (msg::msg) but still seem to get errors. Am I trying to do the impossible or just going about this the wrong way?