Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vectors and abstract classes

In SFML there are a few types of objects (sf::Shape, sf::Sprite, sf::Text) which inherit an abstract base class sf::Drawable. If I create an std::vector can I store all the objects which inherit the sf::Drawable class in that vector?


1 Answers

If you create a std::vector that stores some form of pointer (ideall a smart pointer) you can do it.

like image 158
David Rodríguez - dribeas Avatar answered Jan 02 '26 08:01

David Rodríguez - dribeas



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!