Error: non-aggregate type 'vector' cannot be initialized with an initializer list

Правка en1, от Hawkwatch_19, 2024-05-14 20:42:36

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.

Теги c++, code editor

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en1 Английский Hawkwatch_19 2024-05-14 20:42:36 607 Initial revision (published)