문제

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!

도움이 되었습니까?

해결책

std::vector<Asteroid*> roids;
roids.resize(maxAsteroids);
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top