主题:VC环境下的_beginthread出错问题请教?
我想学习使用多线程,就通过网上资料,在VC中调试一段简单的代码:
#include "windows.h"
#include <process.h>
class ExampleTask
{
public:
friend void taskmain(LPVOID param);
void StartTask();
};
void taskmain(LPVOID param)
{
ExampleTask * pTaskMain = (ExampleTask *) param;
//通过pTaskMain指针引用
}
void ExampleTask::StartTask()
{
_beginthread(taskmain,0,this);
}
int main(int argc, char* argv[])
{
ExampleTask realTimeTask;
realTimeTask.StartTask();
return 0;
}
但编译出错:
D:\MyProgram\pcapPktCapture\multiThread.cpp(18) : error C2065: '_beginthread' : undeclared identifier
执行 cl.exe 时出错.
因为是初学搞不懂,还请大家指教。先谢了!!!
#include "windows.h"
#include <process.h>
class ExampleTask
{
public:
friend void taskmain(LPVOID param);
void StartTask();
};
void taskmain(LPVOID param)
{
ExampleTask * pTaskMain = (ExampleTask *) param;
//通过pTaskMain指针引用
}
void ExampleTask::StartTask()
{
_beginthread(taskmain,0,this);
}
int main(int argc, char* argv[])
{
ExampleTask realTimeTask;
realTimeTask.StartTask();
return 0;
}
但编译出错:
D:\MyProgram\pcapPktCapture\multiThread.cpp(18) : error C2065: '_beginthread' : undeclared identifier
执行 cl.exe 时出错.
因为是初学搞不懂,还请大家指教。先谢了!!!