Menu
Home
Create new Paste
Log in
Code
Theme: cobalt
Theme: eclipse
Theme: elegant
Theme: monokai
Theme: neat
Theme: night
Theme: rubyblue
import std.stdio; interface Transformable { public: void transform(); } mixin template _Transform() { public: void transform() { writeln("transformiere"); } } abstract class Transform { mixin _Transform; } abstract class Drawable { public: void draw() { writeln("drawing"); } } class Shape : Drawable, Transformable { public: mixin _Transform; void Do() { super.draw(); //super.transform(); // multiple_inheritance.d(32): Error: undefined identifier 'transform', did you mean 'class Transform'? //Transformable.transform(); // Error 42: Symbol Undefined _D20multiple_inheritance13Transformable9transformMFZv //Transform.transform(); // multiple_inheritance.d(32): Error: this for transform needs to be type Transform not type multiple_inheritance.Shape this.transform(); // works } } void test1(Transformable t) { t.transform(); } void test2(Drawable d) { d.draw(); } void main() { Shape s = new Shape(); s.Do(); writeln("----"); test1(s); test2(s); }
Result:
Success
/
Return code: 0
/
Compilation time:
1.255
seconds
/
Run time:
0.019
seconds
Application output:
drawing
transformiere
----
transformiere
drawing
Username
Message
Add comment
Paste info
Author:
Namespace
Views:
166
Private:
no
Expires:
Never
Uploaded:
09.07.12 21:55
Votes
:
0
Tweet
Compilation
Compiler:
DMD 2.062
Pointer size:
m64
Actions
Download
Fork
Raw
×
Confirm
Are you sure you want to delete this paste?
There's no way back!
×
Confirm
Reason