| **Navigation:**  [[introduction.htm|Language Reference]] > 5 - Declaration Attributes > Variable and Entity Attributes >====== IMPLEMENTS(add methods to a CLASS) ====== | [[filter set view filter expression .htm|{{btn_prev_n.gif|Previous page}}]][[introduction.htm|{{btn_home_n.gif|Return to chapter overview}}]][[implements inheritance.htm|{{btn_next_n.gif|Next page}}]] | | || **IMPLEMENTS(**//interface//**)** {{blk2blue.jpg|blk2blue.jpg}} | **IMPLEMENTS** | Adds additional methods to a CLASS. | | //interface// | A previously defined INTERFACE structure whose methods will be defined by the CLASS that is implementing the specified interface. | When a class IMPLEMENTS an interface, it inherits all methods that are defined in the INTERFACE. A class may IMPLEMENT multiple INTERFACEs. The class normally defines all methods declared in each INTERFACE that is implemented. We now have support for the re-implementing of INTERFACEs in derived classes. With the new implementation, if the child class has the IMPLEMENTS attribute for an interface already implemented above it in the hierarchy, the compiler builds a new interface VMT. See the [[implements inheritance.htm|IMPLEMENTS Inheritance]] topic **Example 1:** MyInterface INTERFACE ! Interface structure MyProc1 PROCEDURE ! Method prototype MyProc2 PROCEDURE ! Method prototype END MyClass CLASS,IMPLEMENTS(MyInterface) ! Class END MyClass.MyInterface.MyProc1 !Method declaration CODE MyClass.MyInterface.MyProc2 !Method declaration CODE **Example 2:** MyInterface INTERFACE ! Interface structure MyProc1 PROCEDURE ! Method prototype MyProc2 PROCEDURE,BOOL ! Method prototype END MyClass CLASS,IMPLEMENTS(MyInterface) ! Class MyProc1Worker PROCEDURE,VIRTUAL ! Method prototype MyProc2Worker PROCEDURE,BOOL,VIRTUAL ! Method prototype END MyClass.MyProc1Worker PROCEDURE CODE MyClass.MyProc2Worker PROCEDURE CODE RETURN CHOOSE(YEAR(TODAY())>2000) MyClass.MyInterface.MyProc1 !Method declaration CODE !implementation stub calls class method to do real work: self.MyProc1Worker return MyClass.MyInterface.MyProc2 !Method declaration CODE !implementation stub calls class method to do real work return self.MyProc2Worker() MyDerivedClass CLASS(MyClass) ! ,IMPLEMENTS(MyInterface) not allowed !Interface already implemented by parent MyProc2Worker PROCEDURE,BOOL,DERIVED END MyDerivedClass.MyProc2Worker PROCEDURE BooRt BOOL CODE BooRt = parent.MyProc2Worker() IF MONTH(TODAY())=1 THEN BooRt=0. RETURN BooRt **See Also:** [[interface class behavior definition 2.htm|INTERFACE]] [[implements inheritance.htm|IMPLEMENTS Inheritance]]