Reputation:
This code:
class C
{
int opAdd(C b) { return 1; }
private int j;
}
void main()
{
C a;
C c;
int j = a + c;
}
Throws:
"object.Exception: Access Violate - Read at address 0x0"
Upvotes: 0
Views: 200
Reputation: 25187
Classes in D are reference types. You need to instantiate them:
C a = new C();
C b = new C();
Also, opAdd
has been replaced by opBinary!"+"
in D2 (see D2 operator overloading).
Upvotes: 6