Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Pointer to Member Operator?

Pointer to Member Operator?

Scheduled Pinned Locked Moved C / C++ / MFC
comtutorialquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    JamesPrevallet
    wrote on last edited by
    #1

    The amazing yet ellusive ->* operator appears to require an object of a known type. Suppose you want to call a member function of an arbitrary object? For example, in the creation of a service, I designed an interface to allow consumers to pass in a "this" pointer and their callback function. What's the recommended way to dish up the program counter to them when all I have are these two items? void *pThis; typedef BOOL (CALLBACK * LPFGETMESSAGE)(IN EMS_HANDLE hSentMessage, IN CString &Body, IN BOOL bSuccess); I have no way to find out what type of object "pThis" is, nor do I WANT to know. Best of, James Prevallet http://www.mp3.com/JamesPrevallet

    A 1 Reply Last reply
    0
    • J JamesPrevallet

      The amazing yet ellusive ->* operator appears to require an object of a known type. Suppose you want to call a member function of an arbitrary object? For example, in the creation of a service, I designed an interface to allow consumers to pass in a "this" pointer and their callback function. What's the recommended way to dish up the program counter to them when all I have are these two items? void *pThis; typedef BOOL (CALLBACK * LPFGETMESSAGE)(IN EMS_HANDLE hSentMessage, IN CString &Body, IN BOOL bSuccess); I have no way to find out what type of object "pThis" is, nor do I WANT to know. Best of, James Prevallet http://www.mp3.com/JamesPrevallet

      A Offline
      A Offline
      Anders Molin
      wrote on last edited by
      #2

      You can make a generic baseclass, with a virtual callback function, that your costumers have to inherit from. Then, instead of void *pThis; you can say MyBaseClass *pThis; pThis->CallBackFunction(); - Anders Money talks, but all mine ever says is "Goodbye!"

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups