Working on a little thing that randomly generates colored blocks. Anyway, for organization, I have each of the generators - with a method, generate() - in their own class, all of which descend from Generator. The World class holds a collection of Generator * to these, and so can be called as generators[randomIndex]->generate().
//in World.h
static std::vector<Generator *> generators;
//in World.cpp
generators.push_back(&Forest());
//Generator.h
class Generator
{
public:
virtual void generate(sf::Color ** grid, sf::Vector2i size) = 0;
};
//Forest.h
class Forest : Generator
{
public:
void generate(sf::Color ** grid, sf::Vector2i size);
};
The error:
'type cast' : conversion from 'Forest *' to 'Generator *' exists, but is inaccessible
Why does this occur, and how to fix it?