January 09, 2017 How to use mixin import code outside the class definition. | ||||
---|---|---|---|---|
| ||||
mixin template Bar() { override void func() { writeln("Bar.func()"); } } class Foo { void func() { writeln("Foo.func()"); } } void test() { Foo b = new Foo(); b.func(); // calls Foo.func() b = new Foo(); mixin(b, Bar()); b.func(); // calls Bar.func() } It's crazy idea? |
Copyright © 1999-2021 by the D Language Foundation