dimanche 24 mai 2020

How can I pass member function of one class as an argument to member function of another class?

class EmulNet
{
    public:
    int ENrecv(Address *myaddr, std::function<int (void*,char*,int)> fn, struct timeval *t, int 
    times, void *queue); 
};

class MP1Node{
    public:
    int recvLoop();
    int enqueueWrapper(void *env, char *buff, int size);
};

int MP1Node::recvLoop() {
    return emulNet->ENrecv(&(memberNode->addr), std::bind(&MP1Node::enqueueWrapper,this), NULL, 1, &(memberNode->mp1q));

}

Note - emulNet is an object of class EmulNet

Above code doesn't work.

No viable conversion from '__bind<int (MP1Node::*)(void *, char *, int), MP1Node *>' to 'std::function<int (void *, char *, int)>'

Aucun commentaire:

Enregistrer un commentaire