We can easily fix this by using the public getX and getY
Pair operator+(int d, const Pair& other) { int xval = d + other.getX(); int yval = d + other.getY(); return Pair(xval, yval); }