I have a class where I define my variable "int _remaining = 52;" When I try to create an array inside of by class method Deck::shuffle() using this variable I get an error. I can only assign const.
So I tried to add a temporary const variable "const int n = Deck::_remaining" and try to create my array with array[n][2]
My compiler stills complain that it is not const.
So I try to do a "++n;" just to test it. And here I got a contradictory error that now my "n" is const...
What am I missing?
Many thanks!
class Deck {
int _remaining = 52;
public:
Deck();
}
void Deck::shuffle_deck() {
const int n = Deck::_remaining; // creating a const tmp value
n++; // Error that n is a const (I expected that)
char* deck_tmp[n][2]; // Error that n cannot be assigned since it is not a const
}