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 Function for Phase Management

Pointer to Function for Phase Management

Scheduled Pinned Locked Moved C / C++ / MFC
tutoriallearning
4 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.
  • W Offline
    W Offline
    wogerdoger
    wrote on last edited by
    #1

    Greetings, I would like to write a generic CPhaseManagement object, but keep hitting a wall with it being tied to the specific app. The Phases would be something like: InitPhase, IntroPhase, MenuPhase, AppPhase, and ExitPhase with an enumerated type defined in a PhaseSettings.h file ! Each Phase of the App will have it's own specific Phase routines (StartPhase, ProcessPhase and ExitPhase). These of course will be App specific. So I need to know how to make a pointer to a function so that the PhaseManager can call the relevant PhaseStart/exit etc. Any pointers (haha) / comments appreciated. If sex is a pain in the ass, then you are doing it wrong!

    D 1 Reply Last reply
    0
    • W wogerdoger

      Greetings, I would like to write a generic CPhaseManagement object, but keep hitting a wall with it being tied to the specific app. The Phases would be something like: InitPhase, IntroPhase, MenuPhase, AppPhase, and ExitPhase with an enumerated type defined in a PhaseSettings.h file ! Each Phase of the App will have it's own specific Phase routines (StartPhase, ProcessPhase and ExitPhase). These of course will be App specific. So I need to know how to make a pointer to a function so that the PhaseManager can call the relevant PhaseStart/exit etc. Any pointers (haha) / comments appreciated. If sex is a pain in the ass, then you are doing it wrong!

      D Offline
      D Offline
      David Crow
      wrote on last edited by
      #2

      int Foo1( WPARAM, LPARAM )
      {
      }

      int Foo2( WPARAM, LPARAM )
      {
      }

      int (*pFunc)( WPARAM, LPARAM );

      if (some_condition)
      pFunc = Foo1;
      else if (some_other_condition)
      pFunc = Foo2;

      (*pFunc)(parameter_list);


      Five birds are sitting on a fence. Three of them decide to fly off. How many are left?

      W 1 Reply Last reply
      0
      • D David Crow

        int Foo1( WPARAM, LPARAM )
        {
        }

        int Foo2( WPARAM, LPARAM )
        {
        }

        int (*pFunc)( WPARAM, LPARAM );

        if (some_condition)
        pFunc = Foo1;
        else if (some_other_condition)
        pFunc = Foo2;

        (*pFunc)(parameter_list);


        Five birds are sitting on a fence. Three of them decide to fly off. How many are left?

        W Offline
        W Offline
        wogerdoger
        wrote on last edited by
        #3

        cast to pointer to Function hey ! Who would have thought! (Obviously not me) Much Appreciated If sex is a pain in the ass, then you are doing it wrong!

        W 1 Reply Last reply
        0
        • W wogerdoger

          cast to pointer to Function hey ! Who would have thought! (Obviously not me) Much Appreciated If sex is a pain in the ass, then you are doing it wrong!

          W Offline
          W Offline
          wogerdoger
          wrote on last edited by
          #4

          Does this mean that I have to create a pointer to a ? As opposed to a pointer to a function with any set of params. Obviously when I call it, I will have to pass the right param types, but do I have to declare the pointer to have those param types ? Or am I flogging a dead camel ? If sex is a pain in the ass, then you are doing it wrong!

          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