我想重載操作: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