代码无法在服务器VS上运行

时间:2015-07-27 04:56:12

标签: c++ visual-studio-2012 visual-studio-2013 virtual-machine

所以最近我设置了一个虚拟机并安装了VS2012 Professional,我的c ++代码无法正常运行

但是在本地机器上我已经在VS2013上为Windows桌面Express编写了这个C ++代码

#include<iostream>
#include <fstream>
#include <vector>
#include <algorithm>

using namespace std;


int main(){

    ofstream myfile;
    myfile.open("example1.csv");

    vector<int> cats;
    cats = { 1, 2, 3, 4, 5 };
    sort(cats.begin(), cats.end());
    do {

        for (int j = 0; j<cats.size(); j++){

            cout << cats[j] << ',';
            myfile << cats[j] << ',';

        }


        cout << endl;
        myfile << endl;

    } while (next_permutation(cats.begin(), cats.end()));

    myfile.close();

    return 0;

}

这基本上应该让我对声明的向量进行排列,但是我在VS2012 Pro中得到了这个错误

-error C2059: syntax error: '{'
-error C2143: syntax error: missing ';' before '{'
-error C2143: syntax error: missing ';' before '}'
-IntelliSence: expected an expression
-warning C4018 '<':signed/unsigned mismatch 

1 个答案:

答案 0 :(得分:0)

Visual Studio的C ++ 11支持很多。例如,Visual Studio 2012不支持像这样的初始化列表:

cats = { 1, 2, 3, 4, 5 };

Visual Studio 2013确实如此,因此他们正在追赶。无论如何,您的代码在VS2013中工作,而不是在VS2012中,因为2013年增加了更多功能。

Here's a list of what is and isn't supported by version.

欢迎来到我的地狱。我必须使用Visual Studio 2010.我很幸运能够编译2003标准中的内容。我很幸运能够汇编90年代的东西。拜托,上帝,让我升级!

相关问题