Work on a small thing that randomly generates color blocks. In any case, for the organization I have each of the generators - using the generate() method - in my class, all of which come from Generator . The World class contains the Generator * set for them, and therefore can be called 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); };
Error:
'type cast': conversion from 'Forest *' to 'Generator *' exists but not available
Why is this happening and how to fix it?
user1533320
source share