diff --git a/.gitignore b/.gitignore index 4cd59a0..08b3b61 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ appending/appending import/import compclass/compclass copy/copy +structcons/structcons diff --git a/structcons/Makefile b/structcons/Makefile new file mode 100644 index 0000000..f191279 --- /dev/null +++ b/structcons/Makefile @@ -0,0 +1,12 @@ + +TARGET := structcons + +all: $(TARGET) + +$(TARGET): $(TARGET).d + +%: %.d + gdc -o $@ $< + +clean: + -rm -f *.o *~ $(TARGET) diff --git a/structcons/structcons.d b/structcons/structcons.d new file mode 100644 index 0000000..0031385 --- /dev/null +++ b/structcons/structcons.d @@ -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); +}