Default value of class

Jarrett Billingsley kb3ctd2 at yahoo.com
Sun May 20 15:01:28 PDT 2007


"Jarrett Billingsley" <kb3ctd2 at yahoo.com> wrote in message 
news:f2qgao$3176$1 at digitalmars.com...
>
> Doesn't C++ have those ... && reference arguments?  Like int&& ?  You can 
> pass temps to those.  Well I guess those are in C++09, so they're not part 
> of the language yet.

Though D can do this:

struct S
{
    int x;

    static S opCall(int x)
    {
        S s;
        s.x = x;
        return s;
    }
}

void foo(ref S s)
{
    writefln(s.x);
}

void main()
{
    foo(S(4));
}

Which I guess is pretty close. 





More information about the Digitalmars-d mailing list