1
How to declare an array within a class, even if you don’t know what size it will be and leave it accessible throughout the program. Note this class:
class exemplo{
public:
  int tx{0};
  int ty{0};
  int array[tx][ty]; // se eu tentar declarar aqui: não funciona porque os valores de tx e ty não foram obtidas pelo construtor ainda
  exemplo(int tempx,int tempy){
    tx = tempx;
    ty = tempy;
    int array[tx][ty]; //se eu tentar declarar aqui: compila, porem não posso acessar por fora do construtor
  }
int array[tx][ty]; //se eu tentar declarar aqui: Não funciona, dá o erro: error: invalid use of non-static data member ‘grafo::tx’
   int pgrafo[tx][ty];
              ^~
};
How to solve this problem ?
No reason not to
std::vector.– Mário Feroldi
It worked, so much so that I scored the best answer. But it would help if someone had a more intuitive solution
– silash35
Mario, is it possible to create a multidimensional vector ? How ?
– silash35