I try to make queue that can receive pointer to function - and i can't find how to do it
this is my code
struct TaskElement
{
int id;
std::function<void()> func;
void operator()()
{
func();
}
};
int main()
{
MyMath* myMathElement = new MyMath();
myMathElement->Print_1();
Queue<TaskElement> myQueue;
TaskElement t1;
t1.id = 1;
t1.func = myMathElement->Print_1;
TaskElement t2;
t2.id = 2;
t2.func = &myMathElement->Print_2;
myQueue.push(t1); Error !!! &': illegal operation on bound member function expression
myQueue.push(t2); Error !!! &': illegal operation on bound member function expression
auto rec1 = myQueue.pop();
rec1();
std::cin.get();
}
Aucun commentaire:
Enregistrer un commentaire