samedi 31 octobre 2020

Initialize constant to integer value [duplicate]

I am trying to create an array of a size specified by a command line argument. I assign it to a const int using const int size = stoi(argv[3]);. However when I pass this value into an object constructor someConstructor(const int size) and I try to create an array based off that size in the construtor int table[size]; I get "expression did not evaluate to a constant". What am I doing wrong?

Aucun commentaire:

Enregistrer un commentaire