from what you say a friend class would be the best implementation. hopefully the following code should help.
Code:
class B;
class A
{
int p;
friend class B;
public:
int whatIsP() { return p; }
};
class B
{
public:
void setP(A& a, int b) { a.p=b; }
};
int main()
{
A a;
B b;
b.setP(a, 0);
cout << a.whatIsP();
b.setP(a, 1);
cout << a.whatIsP();
return 0;
}
have a look at
www.cplusplus.org for the syntax if ive done it wrong.