我收到这个错误
错误 C2440:“=”:无法从“const BWAPI::UnitType *”转换为“BWAPI::Type *”
在这条线上
this->generalType = &type;
问题是什么?因为 UnitType extends Type 不应该被允许?
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;
}