mardi 16 juin 2020

VS c++ compile template with member function pointers with error

The code like this:

template<class hostClassType, typename returnType, typename ...arguementType>
class Delegate
{
public:
    typedef returnType (hostClassType::*ClassFunctionType)(arguementType...);

    Delegate(hostClassType* obj, ClassFunctionType func)
    {
        m_HostObject = obj;
        m_ClassFunction = func;
    }

private:
    hostClassType* m_HostObject;
    ClassFunctionType m_ClassFunction;
}

Visual Studio 2019 compile it with error:

error C2825: 'hostClassType': must be a class or namespace when followed by '::'

Tried with <typename hostClassType> and <class hostClassType> in the template. none of them works. Does anyone know what is the problem with the code? Thank you very much

Aucun commentaire:

Enregistrer un commentaire