extended initializer lists only available with

This style of initialisation, using braces:

int *multi = new int{7,3,9,7,3,9,7,3};

was introduced to the language in 2011. Older compilers don’t support it; some newer ones (like yours) only support it if you tell them; for your compiler:

c++ -std=c++0x bankNum.cpp

However, this form of initialisation still isn’t valid for arrays created with new. Since it’s small and only used locally, you could declare a local array; this doesn’t need C++11 support:

int multi[] = {7,3,9,7,3,9,7,3};

This also has the advantage of fixing the memory leak – if you use new to allocate memory, then you should free it with delete when you’ve finished with it.

If you did need dynamic allocation, you should use std::vector to allocate and free the memory for you:

std::vector<int> multi {7,3,9,7,3,9,7,3};

Beware that your version of GCC is quite old, and has incomplete support for C++11.

Leave a Comment