0

I am using the Dev c++ application for writing the code in C/C++. When I used the Veter iterator. For, Iterating the array value. Then I am getting this one error. "[Error] in C++98 'array' must be initialized by constructor, not by '{...}'. Also, I am using Window 10.

Code :-

vector<int> array = { 1, 2, 3, 4, 5 };
Amar Kumar
  • 45
  • 10

2 Answers2

2

You are trying to use the so called initializer_list (take a look here if you do not know what they are) which is a way of costructing objects introduced by c++11.

Hence you need to tell your compiler that you want to use c++11 by passing the argument -std=c++11 to the compiler itself.

Take a look at this question to see how to do it.

Davide Spataro
  • 7,319
  • 1
  • 24
  • 36
2

You must change the compiler option to C++11. There is a similar question here: How to change mode from c++98 mode in Dev-C++ to a mode that supports C++0x (range based for)?