From a80d95a714694d92054c3b8852f3fcd2d1e6685d Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Fri, 15 Feb 2013 23:06:34 -0500 Subject: [PATCH] add structcons --- .gitignore | 1 + structcons/Makefile | 12 ++++++++++++ structcons/structcons.d | 25 +++++++++++++++++++++++++ 3 files changed, 38 insertions(+) create mode 100644 structcons/Makefile create mode 100644 structcons/structcons.d 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); +}