Hello.
I have a following situation
class Unit
{
public:
Unit(float startPosX, float startPosY, float MovementRate, int unitSizeX, int unitSizeY, int sprTexID);
};
class UnitPlayerControled :public Unit, public UnitProperties, public EntityBase
{
public:
UnitPlayerControled(float startPosX, float startPosY, float MovementRate, int unitSizeX, int unitSizeY, int sprTexID);
};
class UnitList
{
public:
std::vector<std::unique_ptr<Unit>> unitList;
};
//This is the code i need to call
void EntityManager::AddUnitEntity(EntityBase * unit)
{//...
}
int main()
{
UnitList unitList;
EntityManager objEntity;
//...
unitList.unitList.push_back(std::unique_ptr<Unit>(new UnitPlayerControled(0,0,0,24,24,1)));
unitList.unitList.push_back(std::unique_ptr<Unit>(new UnitPlayerControled(100,100,0,24,24,3)));
unitList.unitList.push_back(std::unique_ptr<Unit>(new UnitPlayerControled(199,199,0,24,24,500)));
objEntity.AddUnitEntity(*(unitList.unitList[0]));//Issue is here
objEntity.AddUnitEntity(*(unitList.unitList[1]));//cannot convert parameter 1 from 'Unit' to 'EntityBase *'
objEntity.AddUnitEntity(*(unitList.unitList[2]));
}
I get error "cannot convert parameter 1 from 'Unit' to 'EntityBase *'" and i do not know to to resolve
I do not know how to pass to the "EntityBase * unit" from the Entity class from UnitPlayerControled.
What is the way i would i execute something like this.