program.cpp:12:140: error: in C++98 ‘x’ must be initialized by constructor

C++98 supports no initializer_list semantics. You have to fall back on arrays which can be initialized with aggregate-lists:

char array[] = { 'a', 'b', 'c' };
vector<char> x(array, array + sizeof(array)/sizeof(char));

If you do not need a dynamic array anyways, you may just go with the C-array.

Edit: Despite being mentioned countless times already, I also highly suggest to use a modern C++ compiler, if available.

Leave a Comment