class B: -------- A
Does this mean that B descends from A ?
If so,
If you made x Private, and in Class A had a GetX() and SetX() function, then you could override these in B to return nothing, or a Null value, ie
Class A
{
const int GetX(){return X;}
int SetX(int mynum){X = mynum;}
}
Class B
{
const int GetX(){return 0;}//As long as X is never 0, you will be ok here
int SetX(int mynum){;}
}
this isn't very elegant, but it should work
If there is no definite need for the classes to descend from each other, you could use friend functions.
But if you need to descend B from A, and C from A, and not give B Access to some of A, then I would rethink the design slightly, (can you make B the Base class, and then Inherit B ->A, and A-> C ?
but not knowing what you are trying to do thats a little hard. (you may get a better answer in the Object Oriented Forum)