+ 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) )

27th Nov 2016, 7:14 PM
Marcell Juhasz
3 Respuestas
0
you need to use out parameter to return two values from the same function
27th Nov 2016, 7:18 PM
Tushar Mishra
Tushar Mishra - avatar
0
you can't return multiple values from a single function!
27th Nov 2016, 9:15 PM
Mohammed Maaz
Mohammed Maaz - avatar
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
28th Nov 2016, 7:38 AM
Marcell Juhasz