+ 1
Why can not my function return like this?
Vector add(Vector &v2) { return Vector(this->getX() + v2.getX(), this->getY() + v2.getY()); } It compiles only when I declare a Vector v3 first, and then return v3. ( ctor: Vector(double,double) )
3 Respuestas
0
you need to use out parameter to return two values from the same function
0
you can't return multiple values from a single function!
0
I tried to return an Object, not two parameters.
1 Vector object is the return value, which gets two parameters when initialized like
return Vector(1.0,1.0)
But it also makes an error