Qbasicnews.com

Full Version: Using Interfaces?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hey, I'm thinking on porting the Audiere library (unless someone else has) which has nothing but classes with virtual functions and was wondering if I can just use a UDT with function pointers within another UDT that contains it's pointer (Vtable ?)

Example (based off PureBasic port which implements interfaces):

Code:
Type RefCounted_VTBL
   ref As Function() As Long                ' Long
   unref As Function() As Long             ' Long
End Type

Type RefCounted
     vtable As RefCounted_VTBL Ptr
End Type

Type AudFile_VTBL
  ref As [RefCounted_VTBL or RefCounted?] ' All audiere classes extend RefCounted
  File_Read As Function (pbuffer As Long,size As Long)      ' long
  File_seek As Function(position As Long, SeekMode As Long)As Long  ' bool
  tell As Function() As Long                       ' long
End Type


I was following the DirectDraw port for reference. Any help would be greatful.