如何通过需要自由函数的成员函数?
问题如下:考虑这段代码:
#include <iostream>class aClass{public:
void aTest(int a, int b)
{
printf("%d + %d = %d", a, b, a + b);
}};void function1(void (*function)(int, int)){
function(1, 1);}void test(int a,int b){
printf("%d - %d = %d", a , b , a - b);}int main (int argc, const char* argv[]){
aClass a();
function1(&test);
function1(&aClass::aTest); // <-- How should I point to a's aClass::test function?
return 0;}我如何使用a's aClass::test作为参数function1?我坚持这样做。
我想访问该班级的成员。
千巷猫影
偶然的你
一只萌萌小番薯
随时随地看视频慕课网APP
相关分类