Interface-Subclasses

Hello Everyone,

ich created an Interface GenX_SaveLoad:

[code]Interface GenX_SaveLoad
Sub Load(s As BinaryStream)
End Sub

Sub Save(s As BinaryStream)
End Sub
End Interface[/code]

Now i created a Class called GenX_Entity:

[code]Class GenX_Entity
Implements GenX_SaveLoad
Sub Load(s As BinaryStream)
// Part of the GenXSaveLoad interface.
Me.ID = s.ReadInteger
End Sub

Sub Save(s As BinaryStream)
// Part of the GenXSaveLoad interface.
s.WriteInteger(Me.ID)
End Sub

ID As Integer = -1
End Class[/code]

Now, i create a Subclass called GenX_Note_Structure:

[code]Class GenX_Note_Structure
Inherits GenX_Entity

Sub Load(s As BinaryStream)
Super.Load(s) // ?
Me.Note = s.ReadString
End Sub

Sub Save(s As BinaryStream)
Super.Save(s) // ?
s.WriteString(Me.Note)
End Sub

Note As String
End Class[/code]

Now the Question: Is the superclasses call Included automatically? Because GenX_Note_Structure inherited the Interface or do I have to call Super.Load manually?

Thanks for your Answers,
Greetings

You have to use Super.

…ok, but why Users should use Interfaces?

If you have only one class then the interface isn’t necessary. Interfaces are for things that are different but you want them to behave in the same manner. Imagine you have a house where you want to give the command to open what can be opened. Doors, windows, cat door etc. There you give all things the open interface and via the interface you can treat the different objects the same.

Xojo, like Java, only supports single inheritance

So something like the BinaryStream is both readable and writeable - but can only inherit from one parent
It can implement as many interfaces as you want