dimanche 6 mai 2018

Cannot use a function pointer void(T::*)()

I am actually having a problem with executing a function pointer, the thing is T being a template and I am not really sure if T::* would even work, I always put derived classes as templates, since I would like the functions to use members of the derived classes, however I get the following error:

error C2064: term does not evaluate to a function taking 0 arguments

I get the error twice

#include "Character.h"
#include "Container.h"
template <class T>
class CAdvancedChar :
    public CCharacter
{
protected:
    std::vector<void(T::*)()> skills;
public:
    virtual void loop_skills(CContainer *container)
    {
        for (unsigned short i = 0; i < skills.size(); i++)
        {
            if (read_is_using_skill(i))
                skills[i]();
        }
    }
    virtual void check_keyboard_state_skills(CContainer* container, CInGame *inGame)
    {
        for (unsigned short i = 0; i < skills.size(); i++)
            onKeyPressedAct(reserved_skills_keys, i, is_using_skill, i)
    }

    CAdvancedChar(short tex_ID,short team, sf::IpAddress ip_address = sf::IpAddress::LocalHost) : CCharacter(tex_ID, team, ip_address)
    {}
    ~CAdvancedChar(){}
};

Aucun commentaire:

Enregistrer un commentaire