#include "stdafx.h"
#include
#include
#include
using namespace std;
class A {
public:
int n;
A(int n) {
this->n = n;
}
void static run1(A &a);
void static run2(A &a);
void static run(A &a);
};
void A::run1(A &a) {
for (int i = 0; i < a.n; ++ i)
cout << "run1" << endl;
}
void A::run2(A &a) {
for (int i = 0; i < a.n; ++i)
cout << "run2" << endl;
}
void A::run(A &a) {
A * p = &a;
HANDLE h1, h2;
h1 = (HANDLE)_beginthreadex(NULL, 0, A::run1, p, 0, 0);
h2 = (HANDLE)_beginthreadex(NULL, 0, A::run2, p, 0, 0);
}
int main()
{
A a(3);
a.run(a);
return 0;
}
我参考了很多资料,都很零碎。最后我不得已把run1(),run2(),run()全部声明为static,还是报错:"Severity Code Description Project File Line
Error (active) argument of type "void (*)(A &a)" is incompatible with parameter of type "_beginthreadex_proc_type"
"求助!!!!!!