Vector Initialisation - C++ -- getting error while initialising using list

65 Views Asked by At
vector<int> arr3 = {3, 6, 9, 12, 15};

I'm trying to initialise the vector by above method and it is throwing the following error:

vectors.cpp:102:16: error: non-aggregate type 'vector<int>' cannot be initialized with an initializer list
    vector<int>arr3 = {3, 6, 9, 12, 15};
               ^      ~~~~~
1 error generated.

C++ version is 14.0.3 I've also tried to run command: clang++ -std=c++ <filename> and command equivalent to this but this is not working.

Initialisation if vector

0

There are 0 best solutions below