I totally interpretted his problem differently.
It seems like you might be asking if you should have x public, or private and use SetX function in public. However, at second glance you seem to be asking if the person at the console changes x, you want the position to change also.
These types of things you, the programmer, have to do yourself, you can just have it auto update or anything. Do it like this:
So if you fill that into your program, whenever x or y is updated, the position is updated also.
//there should be a version where you only want to change x or y
//if you enter 0 in the bool, it changes x, if you enter 1 in the bool, it changes y
void Object::SetX(int p_x)
x = p_x;
void Object::SetY(int p_y)
y = p_y;
I dont understand why you would want it readonly, since x changes, or .. whatever you're trying to do above, so maybe I have the wrong idea here