A
A
Anther2020-02-22 19:02:10
C++ / C#
Anther, 2020-02-22 19:02:10

How to fix a bug with connecting vectors?

I have a Mac (MacBook Pro (13-inch, 2018, Four Thunderbolt 3 Ports). 10.14.2 Mojave). Just downloaded vs code. Installed C++ Intropreter and Code Runner.

I run the following program:

#include <iostream>
#include <vector>
using namespace std;


int main()
{
    vector<int> vec = {1, 3, 5};
   
    return 0;
}


And an error pops up:
error: non-aggregate type 'vector' cannot be initialized with an initializer list

Googled and found that I need to insert this somewhere:
g++ -std=c++11

But I don't know where. And I assume that to run the program, you will need to open the console all the time. But is it possible to do this from vs code?
In general, how to run this program from vs code without error, of course.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question