113. Operator Overloading-I

Question.1

A developer overloads the + operator for a Vector class:

class Vec { public: int x,y;
   Vec(int a, int b): x(a), y(b) {}
   Vec operator+(const Vec& o) const {
       return Vec(x+o.x, y+o.y);
   }
};
Vec v1(1,2), v2(3,4);
Vec v3 = v1 + v2;
printf("%d %d", v3.x, v3.y);

What is the output?

Need Help? Refer to the Quick Guide below

Select Answer