Árvore de páginas

TLPP - LANGUAGE

Como TLPP oferece herança simples e implementação múltipla de interfaces, é possível combinar os dois conceitos para modelar entidades abstratas de sua aplicação.
De certo modo, assim como é proposto em outras linguagens (java, por exemplo), a combinação destes dois mecanismos cria uma similaridade com herança múltipla.
Em seguida, tem-se um exemplo de uma classe filha que herda uma classe pai e implementa duas interfaces.



Um caminho alternativo para aproximar de herança múltipla
#include "tlpp-core.th"

// Uma classe Pai
////////////////////////////////////////////////////////////////////////////////

Class TlppParent
   Public Method new()
   Public Method create()
EndClass

Method new() Class TlppParent
Return Self

Method create() Class TlppParent
Return

// Uma interface
////////////////////////////////////////////////////////////////////////////////

Interface TlppInterface
   Public Method run()
EndInterface

// Uma segunda interface
////////////////////////////////////////////////////////////////////////////////

Interface TlppInterface2
   Public Method run2()
EndInterface

// Uma classe filha que herda a classe TlppParent e implementa TlppInterface e TlppInterface2
///////////////////////////////////////////////////////////////////////////////

Class TlppChild From TlppParent Implements TlppInterface, TlppInterface2
   Public Method new()
   Public Method run()
   Public Method run2()
EndClass

Method new() Class TlppChild
  _Super:New() // construtor da classe pai
  ::Create()   // herança da classe pai
Return Self

Method run() Class TlppChild
Return

Method run2() Class TlppChild
Return
  • Sem rótulos