Question on Interface.

SteveGuo steveguo at outlook.com
Wed Aug 7 00:11:57 PDT 2013


I like the concept of interface, It enforces its successors to 
implement some necessary methods.

Please take a look at the following example:

device.d
---------------------------------
interface device
{
// I want the three methods implemented by its successors
     void PowerOn();
     void PowerOff();
     void Reset();

     string signature; // This is not allowed in D, but every 
device should has a signature.
}

Why it doesn't support non-static members?
Actually in many cases, we need an interface which needs enforce 
its successors to implement necessary methods, meanwhile it needs 
has its own non-static members.


More information about the Digitalmars-d mailing list