我得到了上面的錯誤信息(我Google搜索到,發現是與一個缺少的大括號或東西有關),但是,我看不到這個缺少的括號是哪裏?致命錯誤C1004:發現意外的文件結尾
#include "stdafx.h"
#include <Windows.h>
#include <iostream>
using namespace std;
class Something{
static DWORD WINAPI thread_func(LPVOID lpParameter)
{
thread_data *td = (thread_data*)lpParameter;
cout << "thread with id = " << td->m_id << endl;
return 0;
}
int main()
{
for (int i=0; i< 10; i++)
{
CreateThread(NULL, 0, thread_func, new thread_data(i) , 0, 0);
}
int a;
cin >> a;
}
struct thread_data
{
int m_id;
thread_data(int id) : m_id(id) {}
};
}
只是好奇,爲什麼'main'包裝在一個類中? – Mahesh 2012-04-02 15:01:26
從這裏得到了示例:http://stackoverflow.com/questions/4768294/multithreading-in-c – mezamorphic 2012-04-02 15:07:13
我認爲它必須包裝在一個類中? – mezamorphic 2012-04-02 15:07:22