两架马车::interface接口

  接口类是十分重要的,MenuButton中和MobileIput都得用到,以下是讲述interface的内容。

  1.声明方式

 interface myUSB;

  function Connect(int Con1,int Con2);  

接口中函数不能实现只能声明,同时不能包含影响内存布局的内容,例如只有结构,枚举和常量,不能有变量

  例如var int num;是不对的

  2.接口的实现

  接口实现的方式和Java类似,

  class MyPC extends Object implements(myUSB);

  MyPC类中必须声明接口中声明的所有函数

  

  3.使用接口

  使用接口的方式

  var myUSB USBReference;

  function DoSomting(Obejct anObject)

  {

          USBReference.Connect(con1,con2);

    if(USBReference(anObject)!=none)

           {

                 ...
           }
  }  

原文地址:https://www.cnblogs.com/NEOCSL/p/2942422.html