How to properly pass structs to sub-functions?
BCS
ao at pathlink.com
Thu Sep 18 11:59:41 PDT 2008
Reply to AEon,
> I used an - initially global - struct with many entries to let me
> save all sorts of data. The idea was to let me have to specify only
> *one* parameter in all the subfunctions I use, and to let the
> subfunctions change the data.
>
> Problem: It turns out data changed in the struct, in the
> subfunction, is not remembered in the calling
> function.
> Hopefully someone can point out what I am doing wrong:
>
by default, structs are pass by value, use the "ref" attibut or switch to
a class
void theFn(ref MyStr str){...}
More information about the Digitalmars-d-learn
mailing list