vendredi 1 décembre 2017

Can't & proper way to declare an array of arrays of int in class member c++11

i'm making a simple map with defined size as parameter, i would like it to be stored in my private member variable.

I will show you a simple exemple :

class A {
   public:
   A (const int size) {
     map_size_ = size;
     //or | both will not compile
     int map[size][size];


   }
   private:
    int map_size_;
    int map_[map_size_][map_size_];
}

I know the map_ won't compile, but i wonder how to declare it properly with a const int from the constructor parameter.

Aucun commentaire:

Enregistrer un commentaire