vendredi 11 août 2017

how to get concrete class object from shared_ptr to abstract class objects

I have vector of shared_ptrs to objects that are derived from Abstract class

std::vector<std::shared_ptr<Abstract>> objects;

the following fails:

Concrete* c = objects[0].get()

With:

error: invalid conversion from ‘Abstract*’ to ‘Concrete*

How can I get access to object of concrete type

Aucun commentaire:

Enregistrer un commentaire