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

Revision en1, by 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.

Tags c++, code editor

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English Hawkwatch_19 2024-05-14 20:42:36 607 Initial revision (published)