我需要分配一个带有给定参数的回调函数,因此当事件被触发并调用回调函数时,它会调用带有给定参数的函数。我查看了多个网站,并一直试图找到解决方案,但没有成功。可能是我太笨了,我能做什么?
这是我正在尝试做的一些事情 -
void callbackFunction(int someParameter) {
// Do something here
}
master.ButtonL1.pressed(callbackFunction(3));
// The code above doesn't work, just there to show what I'm wanting to do
最佳答案
您可以使用lambda .
master.ButtonL1.pressed([]{callbackFunction(3);});
关于c++ - 如何为回调函数分配参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56511813/