so I'm making a little snowboarding game. I have a class for obstacles called Obstacle. Now i'm creating a Biome class so I can randomly generate some (2D) terrain. Here is the definition of the Biome class:
class Biome
{
private:
Obstacle * obstsInBiome;
public:
Biome(Obstacle obsts[], int amountOfObsts);
~Biome();
void draw(); // Draw the biome
};
Then here's the constructor
Biome::Biome(Obstacle obsts[], int amountOfObsts)
{
obstsInBiome = new Obstacle [amountOfObsts]; // Creating array to hold the possible obstacles in this biome
for (int x = 0; x < amountOfObsts; x++) // Filling the obstacle array with the obstacles passed in
{
obstsInBiome[x] = obsts[x];
}
}
When I'm trying to allocate the memory to the array obstsInBiome = new Obstacle [amountOfObsts];
I get the error: "no matching function for call to Obstacle::Obstacle()"
Is it not possible to dynamically allocate memory for objects? Can someone suggest a way to store the possible objects in each biome?
Any help is appreciated, thanks