im getting this error
error C2440: ‘=’ : cannot convert from ‘const BWAPI::UnitType *’ to ‘BWAPI::Type *’
at this line
this->generalType = &type;
what is the problem? since UnitType extends Type shouldn’t be permitted?
class CombatEvent {
public:
CombatEvent& setType(CombatEventType type);
Type* getGeneralType() const;
private:
UnitType unitType;
Type* generalType;
}
// implementation
CombatEvent& CombatEvent::setUnitType(const UnitType type) {
this->generalType = &type;
this->unitType = type;
return *this;
}
Remove the
const. This should work. However, you are passing by value. You can pass byconst UnitType&instead. This improves performance. Or course, remove the address-of operator in the offending line as well if you pass by reference.