Redeclaring data members in extended types

BlitzMax Forums/BlitzMax Programming/Redeclaring data members in extended types

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Although I'm not sure why you'd return Object. You'd be as well returning the top-most Super class.


You mean use Create:A()? Probably would work just as well in my example. I was just trying to spit out an example of how you can change the initializing order of extended types and Object is a base Type that is common to every one.
Of course, returning Object makes more sense if you could be extending more than one base class. Suppose you have a Type which works with OpenGL and another that works with DirectX and you need to extend whichever one you need, then you couldn't just return TMyOpenGL or TMyOpenDirectX because then they all would have to return the same thing or you will run into a compiler error.
Type TMyDirectX
    Method Create:Object()
        'Do Stuff
    End Method
End Type

Type TMyOpenGL
    Method Create:Object()
        'Do stuff
    End Method
End Type

Type TMyGraphics Extends TMyDirectX 'Extend TMyOpenGL for OGL programs
   Method Create:Object()
        Super.Create()
        Return Self
    End Method
End Type

Local MyGraphics:TMyGraphics = TMyGraphics(New TMyGraphics.Create())

Of course, I could just create a base TGraphicsDriver class, abstract everything that is needed to be implemented by TMyDirectX and TMyOpenGL, then return TGraphicsDriver. Not sure though, how adding an extra abstracted layer would affect performance (I would imagine that performance wouldn't be affected at all).