re-creating C++'s reference bahavior

swiftcoder swiftcoder at darkcoda.com
Tue Apr 17 11:41:10 PDT 2007


But this comes back to the basic problem:

Vector3f v = n.position;
v.x = 10; // changes n.position.x, since v is a reference to the same instance as n.position is

Daniel Keep Wrote:
> 
> 
> AFAIK, there's really no way to exactly duplicate C++'s references.
> However, if all "position()" is doing is returning a reference to a
> vector, then do you really need a function at all?  If you just use a
> member variable, then the problem disappears.
> 


More information about the Digitalmars-d-learn mailing list