I'm fairly new to c++ and this problem's got me bad.
In my project I'm using SFML libraries to create asteroids. I declared a class named _asteroids and want to create a bunch of asteroid objects inside the class. Someone suggested I stored the objects inside an array. Later I learned that it wasn't possible to store objects inside an array, but you could store pointers to objects.
In summary I want to:
-Create objects inside the _asteroids class
-Store the pointers to those objects inside an array
-Be able to call those objects by their pointers from the array and change their values
How do I go about doing that? Here is some of my code to do with this:
class _asteroids{
float angle; //Angle
sf::Vector2f a_pos; //Position
sf::Vector2f a_vel; //Velocity
void makeAsteroids(int); //This generates the asteroid's appearance
bool Remove(); //If this is false the object is removed
public:
void Update(); //This updates the position
};
std::vectorinstead.int foo[]declares an empty array ofint. C-style arrays needs to have a fixed size at time of compilation, and of course be an array of the objects you want in the array, e.g._asteroids foo[64].asteroids, but notasteroid.