我想在随机头中使用default_random_engine和uniform_real_distribution生成一些随机双数。无法解析类型'std :: default_random_engine'
我使用Eclipse for C/C++ & MinGW来构建我的项目。
- Eclipse版本:4.2.1
- Eclipse CDT的C/C++开发工具版本:8.1.1.201209170703
- Eclipse CDT的GCC交叉编译器支持版本:1.1.0.201209170703
- MinGW的版本:4.6.2 (使用“gcc -v”进行检查)
当我在编辑器中输入std :: default_random_engine时,Eclipse会提示我“Type'std :: default_random_engine'无法解析”。
我已经配置了我的项目,以支持C++ 11功能
- Open Project Properties->C/C++ Build ->Settings->Tool Settings->GCC C++ Compiler->Miscellaneous->Other Flags. Put "-std=c++0x" at the end
- Project Properties->C/C++ General->Preprocessor Include Paths, Macros->[Providers] tab->your Built-in Compiler Settings provider (toolchain dependent). Click on "Workspace Settings" link which gets you to "Settings" property page, select [Discovery] tab and your provider again. There is "Command to get compiler specs", add "-std=c++0x" in there.
然后我写了一个清单初始化向量和范围测试的支持C++ 11,代码工作正常。
vector<int> ivec = {1, 2, 3};
for (int i : ivec)
cout << i << " ";
cout << endl;
这有什么错了“的std :: default_random_engine”,我应该做些什么来解决这个问题?
这可能是随你的编译器的libstdC++不支持较新的标准库功能,但您的编译器确实支持较新的语言功能。 –
尝试std :: tr1 :: default_random_engine –
您_do_包含''?另外,即使Eclipse不能识别它,它是否正确构建呢? –