Is there any real risk to deriving from the C++ STL containers?

The standard containers do not have virtual destructors, thus you cannot handle them polymorphically. If you will not, and everyone who uses your code doesn’t, it’s not “wrong”, per se. However, you are better off using composition anyway, for clarity.

Leave a Comment