Is there any way to create something like this?

RenatoUtsch renatoutsch at gmail.com
Sun Oct 21 07:08:24 PDT 2012


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() {}
}


More information about the Digitalmars-d mailing list