2014-04-05 55 views
3

我試圖生成以下離散分佈的隨機數,發現這個鏈接:如何從命令行啓用'std = C++ 0x'?

http://www.cplusplus.com/reference/random/discrete_distribution/

我編譯他們給出的例子,並得到這個錯誤

C:\Users\Anand\Desktop>g++ random.cpp -o rand 
In file included from c:\mingw\bin\../lib/gcc/mingw32/4.6.2/include/c++/random:3 
5:0, 
      from random.cpp:3: 
c:\mingw\bin\../lib/gcc/mingw32/4.6.2/include/c++/bits/c++0x_warning.h:32:2: err 
or: #error This file requires compiler and library support for the upcoming ISO 
C++ standard, C++0x. This support is currently experimental, and must be enabled 
with the -std=c++0x or -std=gnu++0x compiler options. 
random.cpp: In function 'int main()': 

這告訴我需要啓用'-std = C++ 0x'。這可以在IDE中輕鬆完成,但是如何通過cmd執行此操作?

回答

3

像這樣:

g++ -std=c++0x random.cpp -o random.exe 

對於什麼是值得的,你的編譯器是相當過時。你會很好地更新到現代版本。