[英]Problems with uniform_int_distribution
I have a pretty basic question which after looking around across the internet, I thought I was doing it correct. 我有一个非常基本的问题,在浏览互联网后,我认为我做对了。 I want to generate a random distribution using
uniform_int_distribution
. 我想使用
uniform_int_distribution
生成随机分布。
I have this code in my project, compiled with C++11 standards 我的项目中有此代码,已使用C ++ 11标准进行编译
uniform_int_distribution<> dis(0,5);
I get the error: 我得到错误:
uniform_int_distribution was not declared in this scope.
I thought I was initializing it with the previous statement. 我以为我是用前面的语句初始化它的。
This error is consistent with you leaving off std::
, so you should use it like follows: 此错误与您省略
std::
一致,因此您应按以下方式使用它:
std::uniform_int_distribution<> dis(0,5);
See it working live . 看到它实时运行 。
Note as WhozCraig mentioned you also need to include the random header: 注意,正如WhozCraig提到的那样,您还需要包括随机标头:
#include <random>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.