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

mongodb - Struggling to get ordered results from the last retrieved article, given array of elements to search in -

c# - Pausing a storyboard on TabItem mouse over -

c# - Attribute value in root node of xml Linq to XML -