Sto cercando di sovraccaricare l'operatore C++ == ma im ottenendo alcuni errori ...C++ errore C2662 non può convertire puntatore 'this' da 'tipo const' per 'Tipo e'
errore C2662: 'CombatEvent: : getType': non può convertire puntatore 'this' da 'CombatEvent const' a 'CombatEvent &'
questo errore è in questa linea
if (lhs.getType() == rhs.getType())
vedere il codice sotto:
class CombatEvent {
public:
CombatEvent(void);
~CombatEvent(void);
enum CombatEventType {
AttackingType,
...
LowResourcesType
};
CombatEventType getType();
BaseAgent* getAgent();
friend bool operator<(const CombatEvent& lhs, const CombatEvent& rhs) {
if (lhs.getType() == rhs.getType())
return true;
return false;
}
friend bool operator==(const CombatEvent& lhs, const CombatEvent& rhs) {
if (lhs.getType() == rhs.getType())
return true;
return false;
}
private:
UnitType unitType;
}
qualcuno può aiutarti?
Molto intelligente. Mi ci sono voluti un paio di minuti per cogliere pienamente l'idea. Grazie molto. –