- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我收到这个错误
错误 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;
}
最佳答案
删除 const
。这应该工作。但是,您正在传递值。您可以通过 const UnitType&
代替。这提高了性能。当然,如果您通过引用传递,也可以删除违规行中的 address-of 运算符。
关于c++ - 错误 C2440 : '=' : cannot convert from 'const BWAPI::UnitType *' to 'BWAPI::Type *' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12068779/
刚接触 swift,从书本上学习。他们在示例中使用以下内容: var stepsTaken : Measurement 所以这表明stepsTaken是一个类型为Measurement的变量 我在 A
我有一个 UnitType 实例数组,定义如下: export type MeasurementType = 'weight' | 'length' | 'temperature' | 'pressu
我需要使用 Objective-C 上的 MeasurementFormatter 显示 km/h 值的整数。 有 sample 吗? NSMeasurementFormatter *formatte
Realm Swift 是否支持保存和检索值类型为 Measurement 的数据?这是我要保存的数据的类结构: class Race: Object { @objc dynamic var race
我收到这个错误 错误 C2440:“=”:无法从“const BWAPI::UnitType *”转换为“BWAPI::Type *” 在这一行 this->generalType = &type;
我是一名优秀的程序员,十分优秀!