dimanche 28 juin 2015

How can I initialize array in a C++11 style?

This answer says that C++11 has new feature which allows us to initialize "variable-sized arrays" like this:

auto array = new double[M][N]();

But when I try to do this, I get following error:

array size in new-expression must be constant

I didn't forget to add -std=c++0x in the .pro file. I tested another C++11 features and it works just fine.

Was he wrong? Or am I?

Thanks.

Aucun commentaire:

Enregistrer un commentaire