mirror of
https://github.com/xomboverlord/ldc.git
synced 2026-02-10 08:53:13 +01:00
[svn r117] Initial working implementation of interfaces.
Groundwork for all the different types of class/interface casts laid out.
This commit is contained in:
33
test/interface4.d
Normal file
33
test/interface4.d
Normal file
@@ -0,0 +1,33 @@
|
||||
module interface4;
|
||||
|
||||
interface I
|
||||
{
|
||||
void func();
|
||||
}
|
||||
|
||||
interface I2
|
||||
{
|
||||
void func();
|
||||
}
|
||||
|
||||
class C : I,I2
|
||||
{
|
||||
int i = 42;
|
||||
override void func()
|
||||
{
|
||||
printf("hello %d\n", i);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
scope c = new C;
|
||||
c.func();
|
||||
I i = c;
|
||||
i.func();
|
||||
I2 i2 = c;
|
||||
i2.func();
|
||||
printf("final %d\n", c.i);
|
||||
assert(c.i == 45);
|
||||
}
|
||||
Reference in New Issue
Block a user