Static operator overloads (again)
Giles Bathgate
gilesbathgate at gmail.com
Mon Sep 1 06:11:54 PDT 2008
I am trying to translate the following C# code into D
public class Test
{
public string Name;
public static Test operator +(Test lvalue, Test rvalue)
{
if (lvalue == null) { lvalue = new Test(); lvalue.Name = "foo"; }
if (rvalue == null) { rvalue = new Test(); rvalue.Name = "bar"; }
Console.Write(lvalue.Name);
Console.Write(rvalue.Name);
return rvalue;
}
}
void main()
{
Test T = null;
Test B = null;
T += B;
}
Whilst leaving the syntax of main() untouched.
More information about the Digitalmars-d
mailing list