add property example
This commit is contained in:
parent
3d0f41097f
commit
f557efcb86
1
.gitignore
vendored
1
.gitignore
vendored
@ -8,3 +8,4 @@ copy/copy
|
|||||||
structcons/structcons
|
structcons/structcons
|
||||||
enum/enum
|
enum/enum
|
||||||
copyconstructor/copyconstructor
|
copyconstructor/copyconstructor
|
||||||
|
property/property
|
||||||
|
11
property/Makefile
Normal file
11
property/Makefile
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
TARGET := property
|
||||||
|
|
||||||
|
all: $(TARGET)
|
||||||
|
|
||||||
|
$(TARGET): $(TARGET).d
|
||||||
|
|
||||||
|
%: %.d
|
||||||
|
gdc -o $@ -Wall $<
|
||||||
|
|
||||||
|
clean:
|
||||||
|
-rm -f *.o *~ $(TARGET)
|
22
property/property.d
Normal file
22
property/property.d
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
import std.stdio;
|
||||||
|
|
||||||
|
class A
|
||||||
|
{
|
||||||
|
int a() { return 10; }
|
||||||
|
void a(int x)
|
||||||
|
{
|
||||||
|
writefln("Setting a to %d", x);
|
||||||
|
}
|
||||||
|
void a(int x, int y)
|
||||||
|
{
|
||||||
|
writefln("a(%d, %d)", x, y);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
auto a = new A;
|
||||||
|
writeln(a.a);
|
||||||
|
a.a = 42;
|
||||||
|
a.a(42, 33);
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user