by Xeotroid » Sun Nov 26, 2023 9:57 am
In C++ which has multiple inheritance in general, abstract classes are used, so there is no practical difference there. In languages without multiple inheritance (for good reason, imo, imagine someone trying to do something like class SuperMonster : DoomImp, ZombieMan), multiple interfaces can still be used. The common way to describe them is a "contract" - they have absolutely no implementation of their own*, they just specify method signatures, all of which must be implemented by the classes that use those interfaces.
Taking C# as example, one common interface is IComparable<T>, which, when used and implemented in a class, lets you call the CompareTo() method (declared by the interface, defined by the implementation) for sorting purposes, or IDisposable, which is used by using blocks for automatic clean-up of unmanaged resources after leaving scope. A class can "inherit" from both of them in addition to one actual inheritance, but really it's less of an inheritance and more of a promise to implement CompareTo(T other) and Dispose().
In ZScript, I can imagine more complex mods could utilise this for more navigable code that's less of a spiderweb of inheritances. I myself with my frankly horrible un-navigable code practices might opt to ignore interfaces like I often do in C#, but more skilled programmers might welcome them.
*Let's not get into the shenanigans C# has like default implementations...
In C++ which has multiple inheritance in general, abstract classes are used, so there is no practical difference there. In languages without multiple inheritance (for good reason, imo, imagine someone trying to do something like [c]class SuperMonster : DoomImp, ZombieMan[/c]), multiple interfaces can still be used. The common way to describe them is a "contract" - they have absolutely no implementation of their own[b]*[/b], they just specify method signatures, all of which [b]must[/b] be implemented by the classes that use those interfaces.
Taking C# as example, one common interface is IComparable<T>, which, when used and implemented in a class, lets you call the CompareTo() method (declared by the interface, defined by the implementation) for sorting purposes, or IDisposable, which is used by [c]using[/c] blocks for automatic clean-up of unmanaged resources after leaving scope. A class can "inherit" from both of them in addition to one actual inheritance, but really it's less of an inheritance and more of a promise to implement CompareTo(T other) and Dispose().
In ZScript, I can imagine more complex mods could utilise this for more navigable code that's less of a spiderweb of inheritances. I myself with my frankly horrible un-navigable code practices might opt to ignore interfaces like I often do in C#, but more skilled programmers might welcome them.
*Let's not get into the shenanigans C# has like default implementations...