I'm not a professional programmer, so please don't hesitate to state the obvious.
My goal is to use a std::multiset
container (typedef EventMultiSet
) called currentEvents
to organize a list of structs, of type Event
, and to have members of class Host
occasionally add new Event
structs to currentEvents
. The structs are supposed to be sorted by one of their members, time. I am not sure how much of what I am trying to do is legal; the g++ compiler reports (in "Host.h") "error: 'EventMultiSet' has not been declared." Here's what I'm doing:
// Event.h
struct Event {
public:
bool operator < ( const Event & rhs ) const {
return ( time < rhs.time );
}
double time;
int eventID;
int hostID;
};
// Host.h
...
void calcLifeHist( double, EventMultiSet * ); // produces compiler error
...
void addEvent( double, int, int, EventMultiSet * ); // produces compiler error
// Host.cpp
#include "Event.h"
...
// main.cpp
#include "Event.h"
...
typedef std::multiset< Event, std::less< Event > > EventMultiSet;
EventMultiSet currentEvents;
EventMultiSet * cePtr = ¤tEvents;
...
Major questions
- Where should I include the EventMultiSet typedef?
- Are my EventMultiSet pointers obviously problematic?
- Is the compare function within my Event struct (in theory) okay?
Thank you very much in advance.