still confused about call by reference

Hoenir mrmocool at gmx.de
Wed Oct 31 16:35:16 PDT 2007


> You can read all about it in "Dynamic Initializaion of Structs" here: 
> http://www.digitalmars.com/d/1.0/struct.html 
> 
Thanks a lot for that link!
Though I don't really get the purpose of opCall. For normal member 
initialization struct literals are completely sufficient. opCall would 
just make sense as a copy constructor, but this does not work.

"
     static S opCall(S v)
     {	S s;
	s.a = v.a + 1;
	return s;
     }
}

S s = 3;	// sets s.a to 3
S t = s;	// sets t.a to 3, S.opCall(s) is not called"


More information about the Digitalmars-d-learn mailing list