Normally you would place the vtable in the datasection, and it will be shared by all instances. Overriding a method for all instances is still simple, but overriding a method for just one instance is not.PMV wrote:The vtable points to a list of pointers to the procedurs. If you want to change theTrond wrote:Interfaces make it difficult to allow instances to override methods.
call of one procedure, you only need to override this single pointer. That is the same,
if you want to override the pointer of a prototype.
MFG PMV
The ability to Create non-visual Classes
Re: The ability to Create non-visual Classes
Re: The ability to Create non-visual Classes
i never have used a vTable pointing to a DataSection
I have always created a constructor like this:
Looks like your example with Prototypes, but a little bit better.

MFG PMV

I have always created a constructor like this:
Code: Select all
Interface MyClass
Shout(Msg.s)
EndInterface
Structure MyClass_Struc
vTable.i
*Shout
Name.s
EndStructure
Procedure MyClass_Shout(*Self.MyClass_Struc, Msg.s)
MessageRequester("Shout!", Msg + " from " + *Self\Name + "!")
EndProcedure
Procedure MyClass(Name.s)
Protected *Self.MyClass_Struc = AllocateMemory(SizeOf(MyClass_Struc))
InitializeStructure(*Self, MyClass_Struc)
*Self\vTable = *Self + SizeOf(INTEGER)
*Self\Shout = @MyClass_Shout()
*Self\Name = Name
ProcedureReturn *Self
EndProcedure
Bill.MyClass = MyClass("Bill")
Bob.MyClass = MyClass("Bob")
Bill\Shout("Hello world!")
Bob\Shout("Goodbye, world!")

MFG PMV