add compclass

This commit is contained in:
josh committed 2013-02-15 19:28:28 -05:00
1 parent 80973ceb8c
commit a915413008
3 files changed
+42

No files matched your search

+1
View File
@@ -3,3 +3,4 @@ factorial/factorial
datatypes/datatypes
appending/appending
import/import
compclass/compclass
+12
View File
@@ -0,0 +1,12 @@
TARGET := compclass
all: $(TARGET)
$(TARGET): $(TARGET).d
%: %.d
gdc -o $@ $<
clean:
-rm -f *.o *~ $(TARGET)
+29
View File
@@ -0,0 +1,29 @@
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);
}