add structcons

This commit is contained in:
Josh Holtrop 2013-02-15 23:06:34 -05:00
parent e166405e4a
commit a80d95a714
3 changed files with 38 additions and 0 deletions

1
.gitignore vendored
View File

@ -5,3 +5,4 @@ appending/appending
import/import import/import
compclass/compclass compclass/compclass
copy/copy copy/copy
structcons/structcons

12
structcons/Makefile Normal file
View File

@ -0,0 +1,12 @@
TARGET := structcons
all: $(TARGET)
$(TARGET): $(TARGET).d
%: %.d
gdc -o $@ $<
clean:
-rm -f *.o *~ $(TARGET)

25
structcons/structcons.d Normal file
View File

@ -0,0 +1,25 @@
import std.stdio;
struct Yoda
{
int one;
int two;
};
struct Second
{
int one;
int two;
this(int _one, int _two)
{
one = _two;
two = _one;
}
};
void main(string args[])
{
writefln("%s, %s", Yoda(1,2).one, Yoda(3,4).two);
writefln("%s, %s", Second(1,2).one, Second(3,4).two);
}