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. Callback with meber functions

Callback with meber functions

Scheduled Pinned Locked Moved C / C++ / MFC
questionc++data-structurestutorial
3 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.
  • P Offline
    P Offline
    progDes
    wrote on last edited by
    #1

    Hi, in C++ I can implement callback functions: void (MYFUNC) (int); void func1 (int n) { //some code } void main() { MYFUNC * f = &func1; (*f)(2); //calls func1 (*f)(3); } This is simple enougth. But my question is another. How to implement the same thing on objects member function. i.e. - save object pointer and pointer to the function, then call this function for this object. I know that this is another calling conversion. I could pass object as first parameter, but on some arhitectures it's passed to stack in others to ECX register. I need more accurate code. Does anyone know how to do this? Thanks

    O 1 Reply Last reply
    0
    • P progDes

      Hi, in C++ I can implement callback functions: void (MYFUNC) (int); void func1 (int n) { //some code } void main() { MYFUNC * f = &func1; (*f)(2); //calls func1 (*f)(3); } This is simple enougth. But my question is another. How to implement the same thing on objects member function. i.e. - save object pointer and pointer to the function, then call this function for this object. I know that this is another calling conversion. I could pass object as first parameter, but on some arhitectures it's passed to stack in others to ECX register. I need more accurate code. Does anyone know how to do this? Thanks

      O Offline
      O Offline
      oobimoo
      wrote on last edited by
      #2

      Member Function Pointers and the Fastest Possible C++ Delegates[^]

      P 1 Reply Last reply
      0
      • O oobimoo

        Member Function Pointers and the Fastest Possible C++ Delegates[^]

        P Offline
        P Offline
        progDes
        wrote on last edited by
        #3

        Great thanks!

        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