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:
Code:
class Object
{
private:
int x;
public:
void SetX(int);
void SetY(int);
//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
ChangePos(bool, int);
ChangePos(int, int);
};
void Object::SetX(int p_x)
{
x = p_x;
ChangePos(0, x);
}
void Object::SetY(int p_y)
{
y = p_y;
ChangePos(1, y);
}
int main()
{
Object object;
object.SetX(50);
object.SetY(20);
}
So if you fill that into your program, whenever x or y is updated, the position is updated also.
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