Блог пользователя Hawkwatch_19

Автор Hawkwatch_19, история, 4 недели назад, По-английски

Help me to fix this problem.

#include<bits/stdc++.h>
using namespace std;

int main() {
    vector<int> dir = {1,2,3};
    for (auto d : dir)
    {
        cout<<d<<endl;
    }
    return 0;
}

Whenever I try to run this code in vscode I got this error =>

Is there anyone who ever faced this problem(in mac) and solved it. plz help me. It would be a great relief for me.

Thanks in advance <3.

  • Проголосовать: нравится
  • +9
  • Проголосовать: не нравится

»
3 недели назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

I don't use mac but you can try the following code

#include <bits/stdc++.h>
using namespace std;

int main()
{
    int a[3] = {1, 2, 3};
    vector<int> dir(a, a + 3);
    for (auto d : dir)
    {
        cout << d << endl;
    }
    return 0;
}
  • »
    »
    3 недели назад, # ^ |
    Rev. 4   Проголосовать: нравится +16 Проголосовать: не нравится

    It had been solved already by Heap_OverFlow, but comment got removed due to some reason? Possibly, Heap_OverFlow reported some cheater, who reported heap's comments.

    The soln that heap said and worked with the OP had been

    updating the C++ standard in VS Code to C++11 or later, where the initializer list is supported.

    Modify tasks.json to include the -std=c++11 flag (or a later version like -std=c++14, -std=c++17, etc.) when compiling your code.

    Spoiler
    I wonder if cheat reporting these days lead to removal of such useful comments solving people's doubts?