#include <bits/stdc++.h>
using namespace std;
class vec{
public:
int x;
int y;
vec(int a, int b)
{
x = a; y = b;
}
vec operator+(vec that)
{
vec ans(0, 0);
ans.x = this->x + that.x;
ans.y = this->y + that.y;
return ans;
}
};
int main()
{
vec a(0, 1);
a = a + vec(2, 3); // how does this line work
printf("%d %d\n", a.x, a.y);
return 0;
}
everyone says the constructor does not return anything. it looks like it is returning an object. i tried looking for temporary or unnamed objects but could not find anything specific to this kind of expressions.