Error C2662: 'Event::GetTime' : cannot convert 'this' pointer from 'const Event' to 'Event &'.
This is my code:
#include <iostream>
#include <queue>
#ifndef Person_h
#define Person_h
#include "Person.h"
#endif
using namespace std;
enum EventName
{
_SendMessageToUserInterface,
_SetPNOld,
_IntroduceInfection
};
class Event{
int time;
EventName name;
Person person;
public:
Event(int t, EventName n, Person p)
{
time = t;
name = n;
person = p;
}
int GetTime()
{
return time;
}
Person GetPerson()
{
return person;
}
EventName GetName()
{
return name;
}
bool operator<(const Event& e) const
{
return time < e.GetTime();
}
bool operator==(const Event& e) const
{
return time == e.GetTime() && person == e.GetPerson() && name == e.GetName();
}
};
The error shows on the return lines of the operators' overload methods. I need these overloads to build a set of Event objects.
I am not a very good C++ programmer (more into C#), I can understand what the error says but I do not know how to fix it. Thank you for any suggestion.