Qs about structs and their references WRT C functions and variables
Frits van Bommel
fvbommel at REMwOVExCAPSs.nl
Tue Jan 30 18:12:23 PST 2007
Rick Mann wrote:
> Jarrett Billingsley Wrote:
>
>> Right. 'out' implicitly passes the struct by reference, so if the struct
>> parameter is a return value, then 'out' is the right way to go. That it
>> works with C libraries is something that I didn't know, and something very
>> cool..
>
> It makes for tidy calls where the parameter is used for output. However, I can't seem to do the same for an input parameter. I'd like to do the equivalent of the following C code:
>
> void func(const SomeStruct& inS);
>
> This is identical to
>
> void func(const SomeStruct* inS);
>
> but allows me to call it without adding the & in front of the parameter. It's a bit inconsistent that I can do this with an "out" parameter, but not an "in" parameter.
You could use inout. It's basically a C++ non-const reference.
More information about the Digitalmars-d-learn
mailing list