Static operator overloads are possible why?
Derek Parnell
derek at psych.ward
Thu Jul 5 15:28:24 PDT 2007
On Thu, 05 Jul 2007 15:24:34 -0400, GilesBathgate wrote:
> If you can translate this C# code into D I will give you a medal
Where do I apply for the medal :-)
import std.stdio;
class Test
{
string Name;
static Test opAddAssign(ref Test lvalue, ref Test rvalue)
{
if (lvalue is null)
{
lvalue = new Test();
lvalue.Name = "foo";
}
if (rvalue is null)
{
rvalue = new Test();
rvalue.Name = "bar";
}
writefln("%s", lvalue.Name);
writefln("%s", rvalue.Name);
return rvalue;
}
}
void main()
{
Test T;
Test B;
Test.opAddAssign(T,B);
}
--
Derek Parnell
Melbourne, Australia
skype: derek.j.parnell
More information about the Digitalmars-d
mailing list