vendredi 3 mars 2017

C++ Passing function as parameter (between headers)

My problem is that I want to pass a header's function in another header's function as parameter, but i get an error I don't know what to do with.

header1:

class headerClass1{
public:
void funct1(){}
};

header2:

typedef void (*functCall)()

class headerClass2{
public:
void funct2(functCall fc()){}
};

main:

int main(){

headerClass1 *h1=new headerClass1(parameters);
headerClass2 *h2=new headerClass2(parameters);

h2->funct2(h1->funct1()); 

^returns error "invalid use of void expresion"

...
delete h1;
delete h2;
return 0;
}

Please go in to detail why this doesn't work.

Aucun commentaire:

Enregistrer un commentaire