samedi 23 juin 2018

Cannot convert from 'const shared_ptr

I have declared the following vector:

vector<shared_ptr<base_class> inventory;

I have the following variable:

shared_ptr<derived_class> equipped_item;

I'm trying to do the following:

equipped_item = inventory[0];

I get the following error:

Cannot convert from 'const shared_ptr<base_class>' to 'shared_ptr<derived_class>'

My question is why would I not be allowed to try to set the equipped_item to the selected item in the vector?

Aucun commentaire:

Enregistrer un commentaire