代码(c++):
#include <random>
#include <iostream>
int main()
{
std::random_device rd;
std::mt19937 gen(rd());
std::uniform_int_distribution<> distrib(1, 6);
for (int n=0; n<10; ++n)
std::cout << distrib(gen) << ' ';
std::cout << '\n';
}
排除代码问题,为何就报错了呢?
此为编译之后的截图:

上面那个报错文件的具体内容:
// Copyright (C) 2007-2014 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file bits/c++0x_warning.h
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{iosfwd}
*/
#ifndef _CXX0X_WARNING_H
#define _CXX0X_WARNING_H 1
#if __cplusplus < 201103L
#error This file requires compiler and library support for the \
ISO C++ 2011 standard. This support is currently experimental, and must be \
enabled with the -std=c++11 or -std=gnu++11 compiler options.
#endif
#endif
报错的具体内容:
35 0 C:\Program Files (x86)\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\4.9.2\include\c++\random In file included from C:/Program Files (x86)/Dev-Cpp/MinGW64/lib/gcc/x86_64-w64-mingw32/4.9.2/include/c++/random
1 C:\Users\qeadz\Desktop\test随机数.cpp from C:\Users\qeadz\Desktop\test随机数.cpp
32 2 C:\Program Files (x86)\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\4.9.2\include\c++\bits\c++0x_warning.h [Error] #error This file requires compiler and library support for the ISO C++ 2011 standard. This support is currently experimental, and must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
C:\Users\qeadz\Desktop\test随机数.cpp In function 'int main()':
5 5 C:\Users\qeadz\Desktop\test随机数.cpp [Error] 'random_device' is not a member of 'std'
6 5 C:\Users\qeadz\Desktop\test随机数.cpp [Error] 'mt19937' is not a member of 'std'
7 5 C:\Users\qeadz\Desktop\test随机数.cpp [Error] 'uniform_int_distribution' is not a member of 'std'
7 35 C:\Users\qeadz\Desktop\test随机数.cpp [Error] expected primary-expression before '>' token
7 49 C:\Users\qeadz\Desktop\test随机数.cpp [Error] 'distrib' was not declared in this scope
9 30 C:\Users\qeadz\Desktop\test随机数.cpp [Error] 'gen' was not declared in this scope
怎么解决这个问题? 我的VC调了半天也调不好,只能先用devc++了