Rohit said:
I have two classes A and B, A creates an object of B b_ob. A has a
private variable x. Now I need to change the value of x from the object
b_ob.
I hope the problem is clear, can someone suggest a way of doing so!!
Rohit
As Bjorn notes, bi-directional coupling is not a good idea. You can
still get much the same result, but do it in a much better way, by using
the idea of a 'listener'.
In other words, class A creates class B. Class B offers a way for
interested parties to listen out for a certain something happening - A
registers itself as an interested party... then, when the interesting
thing happens (like some sort of change in B), class A gets notified,
and can inquire of B what state it is in.
If you want more details of this, google for "listener pattern" or
"subscriber/observer".
Telling us your requirement in more detail wouldn't hurt! Even if you
provided an example scenario, that would allow us to communicate more
clearly...