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

Popular posts from this blog

c# - How Configure Devart dotConnect for SQLite Code First? -

c++ - Clear the memory after returning a vector in a function -

erlang - Saving a digraph to mnesia is hindered because of its side-effects -