import std.stdio; class Foo { public: int a; int b; override bool opEquals(Object o_other) { Foo other = cast(Foo) o_other; return a == other.a && b == other.b; } }; void main(string[] args) { Foo f = new Foo(); f.a = 1; f.b = 2; Foo g = new Foo(); g.a = 1; g.b = 2; Foo h = new Foo(); h.a = 1; h.b = 3; writefln("f == g: %s", f == g); writefln("f == h: %s", f == h); writefln("g == h: %s", g == h); }