still confused about call by reference
Jarrett Billingsley
kb3ctd2 at yahoo.com
Thu Nov 1 05:20:33 PDT 2007
"Hoenir" <mrmocool at gmx.de> wrote in message
news:fgcaem$2rju$1 at digitalmars.com...
>> In D that's written:
>>
>> void foo(ref Struct S)
>> {...}
>>
>> And called like:
>>
>> Struct s;
>> foo(s);
>>
>> --bb
>
> Ok, but ref is an alias for inout atm. And I think "in" is implicitly used
> if nothing other is specified, isn't it?
> So how would I pass a struct by reference but without being able to write
> (const & in C++)? and does this make sense(why is struct a value type)?
>
> Please excuse my noob questions. :-)
Your question was answered in the very first reply to your OP, by Derek:
void foo(const ref S s)
{
}
And it was also mentioned that 'const ref' crashes the compiler.
More information about the Digitalmars-d-learn
mailing list