I am compiling this simple code as g++ main.cpp -o main -std=c++03
#include <vector>
int main(){
std::vector<int> array;
std::vector<int> array2 = { 9, 7, 5, 3, 1 };
}
And Im getting the following compilation error:
main.cpp: In function ‘int main()’:
main.cpp:39:18: error: in C++98 ‘array2’ must be initialized by constructor, not by ‘{...}’
std::vector array2 = { 9, 7, 5, 3, 1 };
^~~~~~
main.cpp:39:43: error: could not convert ‘{9, 7, 5, 3, 1}’ from ‘’ to ‘std::vector’
std::vector array2 = { 9, 7, 5, 3, 1 };
It seems that even though that I am compiling with the -std=c++03
(where the initialization list are available), I am still using C++98 standard. Why is this happening?
I know that this code will compile with newer standards.