Announcement

Collapse
No announcement yet.

Pointers to objects?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Stuart McLachlan
    replied
    Originally posted by George Deluca View Post
    Thanks guys.

    Bob: OK, yours is straightforward, but what is 'x' defined as?

    George
    (OOP is clear in concept, murky in the details)
    The interface of the class you want to use.

    Leave a comment:


  • George Deluca
    replied
    Thanks guys.

    Bob: OK, yours is straightforward, but what is 'x' defined as?

    George
    (OOP is clear in concept, murky in the details)

    Leave a comment:


  • Edwin Knoppert
    replied
    What was i thinking?

    Leave a comment:


  • Bob Zale
    replied
    Originally posted by Edwin Knoppert View Post
    Local x as ... (interface name)
    x = nothing ' make sure an existing reference is released.
    Poke dword VarPtr( x ), ObjPtr(currentobject)
    x.addref()
    x.dosomething()
    release:
    x = nothing or just let it go out of scope (exit function).
    I'm sorry, but that's not a good idea. Not good at all. It attempts to circumvent everything the compiler does for you automatically to protect you and prevent leaks. The following code accomplishes the same thing with complete safety and accountability:

    x = currentobject
    x.dosomething()


    Best regards,

    Bob Zale

    Leave a comment:


  • Edwin Knoppert
    replied
    Local x as ... (interface name)

    x = nothing ' make sure an existing reference is released.

    Poke dword VarPtr( x ), ObjPtr(currentobject)
    x.addref()

    x.dosomething()

    release:
    x = nothing or just let it go out of scope (exit function).

    Leave a comment:


  • José Roca
    replied
    ???

    Tabs(x).<method name>

    Leave a comment:


  • George Deluca
    started a topic Pointers to objects?

    Pointers to objects?

    OK, I'm just doing some preliminary stuff in learning OOP stuff, so bear with me.

    If I have an array of Objects, one of which is 'active' at a time.

    Can I create a pointer to the active object? i.e.

    Code:
    (Sort of)
    GLOBAL Tabs()    AS iTabData                       ' Table of active tab objects
    DIM ActiveTab    AS CLASS POINTER              ' (doesn't compile)
    ActiveTab = VARPTR?/CODEPTR?(Tabs(x))       ' Assign pointer
    What is the best method (efficiency and coding ease) to reference the active object's methods etc. from the active entry?

    Or am I Waaayyyy out in left field?

    George
Working...
X