c++ - Modify an object without using it as parameter -


I have a global object "X" and a class "A". I need A in A function F, which has the ability to modify the contents of X.

For some reason, there can be no data member of X A (but in A, in the form of X, some members may be Y), and also, F can not have any parameters, So I can not give X as a parameter in F (Here A is a dialog and F is a slot without any parameters, such as ())

How can I modify the F in X if I can not pass x in it ? Is there a way to find out that the "X" object needs to be modified ?? I try to add something like SetItem to specify x in A, but failed.

If you want to refer TF to the world, then you "worker" The method can 'set' it on the object before calling it. E.g.

  class A {public: a): member_x (NULL) {} zero set x (x * an_x) {member_x = an_x; } Zero F (); {Member_x-> Manipur (); } Private: X * member_x; }; X global_x; A global_a; Zero Dust () {global_a.Setx (& amp; global_x); Global_a.f (); }  

Comments