我想重载操作:C++敌不过运算符*
static Vector operator*(float s, Vector right){
Vector result(right.getX()*s, right.getY()*s, right.getZ()*s);
return result;
}
当我想用它:
Vector a(0,1,5)
Vector v(4*a);
我:
error: no match for 'operator*' (operand types are 'int' and 'Vector')
有什么不对?
请发布[MCVE](http://stackoverflow.com/help/mcve)。 – juanchopanza 2014-10-04 15:34:40
这个'operator *'声明在哪里?为什么它是静态的? – Shoe 2014-10-04 15:34:48
你试过Vector v(4.0 * a); – rahulroy9202 2014-10-04 15:36:01