I need to write some method to accomplish one thing and I've no idea how to do it. I'd appreciate any help.
Suppose we have a method
void m1(int z) {}
which is called like this:
int x; ... m1(x);
Basically I need to make sure that method m1 is using exactly the 'x' field that I need. Not the value of the 'x' field but that it's pointing to the field 'x' and not some other field of this or any other class.
To be more specific I was going to write an if-statement meaning:
if (z is pointing to the field x) return true;
and I don't know how to realize that pointing condition. Is there a standard method for such evaluation?
Thank you very much for your replies, all of you guys.
@durbnpoisn, @Boris the Spider
The code per se doesn't exist yet but I'm trying to elaborate the approaches. I'm not an experienced programmer that's why it may look weird. Sorry for that.
But if it helps my task is to make several 'switch' buttons that when are pushed toggle off certain fields and methods from different parts of the code as if they never been used.
Like for example, the code line looks like that supCrossVal = x^realOpt/setPower(mine)
with all switches off and it should execute like it's supCrossVal = x^realOpt
when SWITCH1 is on.
The problem is that the initial code is quite big (so as the number of related calls) and the number of switches would be around 10-15 and some of the swithes can turn off the same methods and fields. So it seemed to me that adding if-statements (checking whether switchs are on or off) to every field or method call will make the code too hard to read. And overloading methods for each switch seemed too straightforward and code littering as well. So I was thinking of a simple method based on that idea of pointing.