Is there a way to have a function return a editable reference to some internal data. Here’s an example I hope helps show what I mean.
class foo { public int value; } class bar { bar() { m_foo = new foo(); m_foo.value = 42; } private m_foo; foo getFoo(){return m_foo;} } class main { int main() { bar b = new bar(); b.getFoo().value = 37; } }
The return of getFoo() according to ‘==’ is the same as the internal m_foo until I try to edit it. In c/c++ I’d return a reference or pointer.
Actually, your code sample, after some cleaning up, does demonstrate that when you assign 37 to value, you are changing bar’s interman m_foo too. So the answer is, your function is returning a reference type. Now, maybe your real code is different, and it’s returning not an reference type but an int, a value type, or string, a kind of special beastie…
More about reference vs value types: http://www.albahari.com/valuevsreftypes.aspx