HOSOKAWA Kenchi wrote:
Hello,
Interface member functions do not have implementations.
This specification prevents to implement macro-like small functions which won't be overridden.
It seems that interfaces are possible to have function implementations if the
function is ensured not to be overridden.
Hence following list will possibly avoid problems in multiple inheritance.
interface I
{
void f(int);
final void f_twice(int i) { f(i); f(i); }
}
class C : I {...}
(new C).f_twice(1);
This list would be almost equivalent to another list
interface I
{
void f(int);
}
void f_twice(I i, int n) { i.f(n); i.f(n); }
class C : I {...}
f_twice((new C), 1);
If you want this then you need abstract classes.
http://www.digitalmars.com/d/1.0/attribute.html#abstract
abstract class A
{
abstract void f(int);
final void f_twice(int i) { f(i); f(i); }
}
class B : A { }
(new B).f_twice(1);