add copy example

This commit is contained in:
josh committed 2013-02-15 20:05:45 -05:00
1 parent a915413008
commit e166405e4a
3 files changed
+46

No files matched your search

+1
View File
@@ -4,3 +4,4 @@ datatypes/datatypes
appending/appending
import/import
compclass/compclass
copy/copy
+12
View File
@@ -0,0 +1,12 @@
TARGET := copy
all: $(TARGET)
$(TARGET): $(TARGET).d
%: %.d
gdc -o $@ $<
clean:
-rm -f *.o *~ $(TARGET)
+33
View File
@@ -0,0 +1,33 @@
import std.stdio;
struct S
{
int a;
int b;
};
class C
{
int a;
int b;
};
void main(string[] args)
{
S s1;
s1.a = 3;
s1.b = 4;
S s2 = s1;
s2.a = 5;
s2.b = 6;
writefln("S: %d, %d; %d, %d", s1.a, s1.b, s2.a, s2.b);
C c1 = new C();
c1.a = 10;
c1.b = 11;
C c2 = c1;
c2.a = 12;
c2.b = 13;
writefln("C: %d, %d; %d, %d", c1.a, c1.b, c2.a, c2.b);
}