请教一下c++问题(报错不知道该怎么改)

来源:百度知道 编辑:UC知道 时间:2024/06/05 14:35:46
#include <iostream>
using namespace std;

class A
{
public:
A(){}
~A(){}
void run(void)
{
cout << "123456789" << endl;
}
};
int ooc (void*(*start_routine)(void *), void* arg)
{
(*start_routine)(arg);
return 0;
}
int main()
{
A a;

ooc(A::run,NULL);//出错,不知道该怎么改请高手帮忙
return 0;
}
我想知道应该如何改,我改不来,能不能写出来,谢谢
要在ooc里面调用run函数

#include <iostream>
using namespace std;

class A
{
public:
A(){}
~A(){}
void run1(int n)
{
cout << n << endl;
}
void run2(int n)
{
cout << n*n << endl;
}
};

typedef void (A::*start_routine)(int);

int ooc (start_routine sr, int arg)
{
(A().*sr)(arg);
return 0;
}

int main()
{
ooc(&A::run1, 5);

start_routine x = &A::run2;
ooc(x, 6);

return 0;
}

void run(void) 函数不能传给
void*(*start_routine)(void *)....类型不匹配