I have a class, Tile
, that has a constructor with parameters of a Color
object:
class Tile
{
public:
static const int size = 32;
Tile();
Tile(Color &color);
void render(int x, int y);
Color getColor();
~Tile();
private:
Color _color;
};
Then I have a subclass, TileGrass
, which inherits Tile
:
class TileGrass : public Tile
{
public:
TileGrass();
~TileGrass();
};
Now the issue is that the TileGrass
needs to inherit the Tile
constructor with the Color parameters. But, the TileGrass
object already knows what color it needs to give to the superclass, so I don't want to have to pass in a Color
object when creating a new TileGrass
object. In Java I can do something like this:
public class TileGrass extends Tile {
public TileGrass() {
super(color object);
}
}
How can I do something like this in C++?