I am new to c++ and I would appreciate if someone could help solving following problem.
When I want to create an array (Arr) with variable size (S), I do in the following way:
const int S=10;
int Arr[S];
However, in the code I am trying to write, I need to choose S from a Table. Let say I have following table:
int Table[3]={11, 21, 31};
and I choose S from the table and define Arr
const int S=Table[0];
int Arr[S];
I cannot compile this code because I get an error that S must have a constant have constant value.
I would appreciate any help/hint.
std::vector.std::vectorin C++Tableconst as well, orSisn't truely const, which explains the error.