Question OOP-POLY-0044
MediumWhat is the output of this code?
#include <iostream>
using namespace std;
class V {
public:
int x, y;
V(int a, int b) : x(a), y(b) {}
V operator+(const V &o) const { return V(x + o.x, y + o.y); }
};
int main() {
V a(1, 2), b(3, 4);
V c = a + b + a;
cout << c.x << "," << c.y;
}
- A.
5,6
- B.
5,8
- C.
Sign up free to see the answer and a step-by-step explanation.