# include
# include
# include
# include
# include
# include
using namespace std;
Int main () {
Const int sz=10;
VectorIvec;
Srand ((unsigned) time (NULL));
For (int I=0; The I!=sz; I++)
{
Ivec. Push_back (rand () % 100);
Cout & lt;};
//const int b=ivec. The size ();
Auto b=ivec. The size ();
Int a [b];
}
Error problem not solve, b is const int type, Daniel glad, thank you very much
CodePudding user response:
C + + array must be able to in the compiler to determine the amount of const, running period are not determinedC99 only can use the dynamic array, but can't use the STL c
CodePudding user response:
Since the size of the b is unknown, you can write int a [sz] can also write a=new int * int [b]