编译代码块中的线程程序时出错

1 c++ codeblocks

我的线程程序是:

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

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

int main()
{
     thread i(&t);
     cout <<"from main\n";
     i.join();
}
Run Code Online (Sandbox Code Playgroud)

但它在代码块中显示以下错误:

1)'thread ' was not declared in this scope
2)expected ';' before 'i'
3)'i' was not declared in this scope 
Run Code Online (Sandbox Code Playgroud)

我该如何解决?我正在使用Windows和代码块12.11

Min*_*ina 6

首先,你是在Windows或Linux?

如果您使用的是Linux,则必须使用C++ 11支持进行编译.只需将-std = c ++ 11传递给g ++.Windows无法帮助你.