add structcons
This commit is contained in:
parent
e166405e4a
commit
a80d95a714
1
.gitignore
vendored
1
.gitignore
vendored
@ -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
12
structcons/Makefile
Normal 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
25
structcons/structcons.d
Normal 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);
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user