C++ Declare array whose size value from const array -
i'm trying define stack c-style array size taken const array , known in compile-time.
const int size[2]={100, 100}; int ar[size[0]]; //error: expression must have constant value
it fails. how can fixed?
"array size taken const array , known in compile-time"
with c++11 can have :
constexpr int size[2]={100, 100}; // size[0] compile-time constant
use -std=c++11
or -std=c++0x
compile
Comments
Post a Comment