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. how to use ::*

how to use ::*

Scheduled Pinned Locked Moved C / C++ / MFC
game-devalgorithmshelptutorial
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.
  • A Offline
    A Offline
    Anonymous
    wrote on last edited by
    #1

    I have seen some code recently in the Unreal Tournament public source code that uses types like "void(UObject::*Func)( FFrame& TheStack, RESULT_DECL );" and I am trying to figure out how to use this in my own code. I have written something like below but I always get the error "C2064: term does not evaluate to a function" class A { public: void TestFunc() { printf("Hello\n"); } }; void Test(void(A::*Prm1)(void)) { Prm1(); } int main(int argc, char **argv) { Test(A::TestFunc); return 0; } It won't even let me cast it to a DWORD or any other types but you must be able to do something with it or it would not exist. So is there anyone here who can tell me how to use this (I dont even know what to call it), I have tried searching but all the search engines that I have tried have problems with "::*".

    R 1 Reply Last reply
    0
    • A Anonymous

      I have seen some code recently in the Unreal Tournament public source code that uses types like "void(UObject::*Func)( FFrame& TheStack, RESULT_DECL );" and I am trying to figure out how to use this in my own code. I have written something like below but I always get the error "C2064: term does not evaluate to a function" class A { public: void TestFunc() { printf("Hello\n"); } }; void Test(void(A::*Prm1)(void)) { Prm1(); } int main(int argc, char **argv) { Test(A::TestFunc); return 0; } It won't even let me cast it to a DWORD or any other types but you must be able to do something with it or it would not exist. So is there anyone here who can tell me how to use this (I dont even know what to call it), I have tried searching but all the search engines that I have tried have problems with "::*".

      R Offline
      R Offline
      Robert A T Kaldy
      wrote on last edited by
      #2

      Try this:

      class A
      {
      public:
      void f() { printf("Hello\n"); }
      };

      void Test(void (A::*fun)(void))
      {
      A a;
      (a.*fun)();
      };

      void main()
      {
      Test(&A::f);
      }

      If you call a non-static function via pointer-to-member, you have to specify a instance of class, that is passed to the member function. Robert-Antonio "Love, truth and electric traction must gain victory over hate, lie and diesel traction."

      A 1 Reply Last reply
      0
      • R Robert A T Kaldy

        Try this:

        class A
        {
        public:
        void f() { printf("Hello\n"); }
        };

        void Test(void (A::*fun)(void))
        {
        A a;
        (a.*fun)();
        };

        void main()
        {
        Test(&A::f);
        }

        If you call a non-static function via pointer-to-member, you have to specify a instance of class, that is passed to the member function. Robert-Antonio "Love, truth and electric traction must gain victory over hate, lie and diesel traction."

        A Offline
        A Offline
        Anonymous
        wrote on last edited by
        #3

        Thanks alot, thats what I needed.

        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