1

私のスレッドプログラムは次のとおりです。

#include<iostream>
#include<thread>
using namespace std;

void t()
{
    cout<<"from thread\n";
}

int main()
{
     thread i(&t);
     cout <<"from main\n";
     i.join();
}

しかし、コードブロックに次のエラーが表示されます:

1)'thread ' was not declared in this scope
2)expected ';' before 'i'
3)'i' was not declared in this scope 

どうすれば解決できますか? Windows とコードブロック 12.11 を使用しています。

4

2 に答える 2

6

まず、Windows と Linux のどちらを使用していますか?

Linux を使用している場合は、C++11 サポートでコンパイルする必要があります。-std=c++11 を g++ に渡すだけです。窓についてはお手伝いできません。

于 2013-04-10T14:29:51.450 に答える