Pergunta

Asteroid* rocks[maxAsteroids] = {};

So Asteroids is a pointer to a class, at least thats how I understand it. My question is I can't have maxAsteroids be a const, and I know it can't be a simple variable. So what is the proper way to initialize a variable size to a pointer array? This feels like a misunderstanding on my part of syntax, but I'm just not getting it. Appreciated!

Foi útil?

Solução

std::vector<Asteroid*> roids;
roids.resize(maxAsteroids);
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top