Thread: Storing a function argument

  1. #1
    Registered User
    Join Date
    Dec 2005
    Posts
    17

    Storing a function argument

    Ok im trying to hook that function
    Code:
    void __stdcall ZCharacterManagerFindHook(MUID uid)
    {
    }
    I want to know how do i store the arguments value to use it latter.
    Thanks

  2. #2
    Registered User
    Join Date
    Aug 2002
    Location
    Hermosa Beach, CA
    Posts
    446
    A functor is a class that acts like a function. It overloads the function call operator:

    Code:
    class ZCharacterManagerFindHookFunctor {
        MUID muid_;
        public:
        ZCharacterManagerFindHookFunctor(MUID m)
        {
            muid_ = m;
        }
    
        void operator()() {
            ZCharacterManagerFindHook(muid_);
        }
    };
    
    void func(ZCharacterManagerFindHookFunctor& f)
    {
        // Invoke the functor
        f();
    }
    int main()
    {
        MUID m;
        ZCharacterManagerFindHookFunctor f(m);
    
        // Pass the functor to a function, or store it in a data structure,
        // or whatever
        func(f);
    
        return 0;
    }
    The crows maintain that a single crow could destroy the heavens. Doubtless this is so. But it proves nothing against the heavens, for the heavens signify simply: the impossibility of crows.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Compiling sample DarkGDK Program
    By Phyxashun in forum Game Programming
    Replies: 6
    Last Post: 01-27-2009, 03:07 AM
  2. Undefined Reference Compiling Error
    By AlakaAlaki in forum C++ Programming
    Replies: 1
    Last Post: 06-27-2008, 11:45 AM
  3. dllimport function not allowed
    By steve1_rm in forum C++ Programming
    Replies: 5
    Last Post: 03-11-2008, 03:33 AM
  4. Replies: 8
    Last Post: 03-10-2008, 11:57 AM
  5. doubt in c parser coding
    By akshara.sinha in forum C Programming
    Replies: 4
    Last Post: 12-23-2007, 01:49 PM