Is there any way to create something like this?
Jacob Carlborg
doob at me.com
Sun Oct 21 07:44:00 PDT 2012
On 2012-10-21 16:08, RenatoUtsch wrote:
> Sorry, the code is wrong, the fixed code is:
>
> void main() {
> GeneralLibrary library = createLibrary("1.0");
> GeneralLibrary library11 = createLibrary("1.1");
> GeneralLibrary library12 = createLibrary("1.2");
> GeneralLibrary library2 = createLibrary("2.0");
>
> library.func1(); // Should work
> library.func11(); // Should fail
> library.func12(); // Should fail
> library.func2(); // Should fail
>
> library11.func1(); // Should work
> library11.func11(); // Should work
> library11.func12(); // Should fail
> library11.func2(); // Should fail
>
> library12.func1(); // Should work
> library12.func11(); // Should work
> library12.func12(); // Should work
> library12.func2(); // Should fail
>
> library2.func1(); // Should fail
> library2.func11(); // Should fail
> library2.func12(); // Should fail
> library2.func2(); // Should work
> }
>
> class Library_1_0 {
> void func1() {}
> }
>
> class Library_1_1 : Library_1_0 {
> void func11() {}
> }
>
> class Library_1_2 : Library_1_1 {
> void func12() {}
> }
>
> class Library_2_0 {
> void func2() {}
> }
You can probably make some kind of proxy using opDispatch:
http://dlang.org/operatoroverloading.html#Dispatch
--
/Jacob Carlborg
More information about the Digitalmars-d
mailing list