Skip to content

DelegatesinC++

Simon Jackson edited this page Jun 7, 2017 · 1 revision

Delegates in C++

Delegates are function pointer containers that are used as a generic form of holding function pointers.

    template<class T>
    class ZDelegate
    {
    public:
        List<T> functionList;
        void operator += (T h)
        {
            if(!functionList.Contains(h))
                functionList.AddItem(h); 
        }
 
        void operator -= (T h)
        {
            if(functionList.Contains(h))
               functionList.RemoveItem(h); 
        }
    };
Clone this wiki locally