<p>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.</p>

<pre><code>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;
    }
}
</code></pre>

<p>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.</p>

You're already returning the reference of
```
foo
```
in
```
getFoo
```
(this happens by default). So any changes that you make to the return value of
```
getFoo
```
will be reflected in the internal
```
foo
```
data structure in
```
bar
```
.