samedi 29 septembre 2018

Why is not possible to declare an array with a constant expression?

I have a two dimensional std::array

std::array<std::array<String, nHieght>, nWidth> dataTable;

nHieght and nWidth are constant variables, which I don't know their values for diferent dataTables, and the only possible way to get their values is using a function call.

const size_t nHieght = dcmImage->getHeight();
const size_t nWidth = dcmImage->getWidth();

but that is not possible, and this is what I get as an Error:

error: the value of ‘nHieght’ is not usable in a constant expression
 ‘nHieght’ was not initialized with a constant expression

the same is for nWidth of course.

Aucun commentaire:

Enregistrer un commentaire