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.
More Related Contents:
- Thou shalt not inherit from std::vector
- Why should one not derive from c++ std string class?
- What is the easiest way to initialize a std::vector with hardcoded elements?
- How do I specify a pointer to an overloaded function?
- How to overload std::swap()
- Initializing a static std::map in C++
- How do I sort a vector of pairs based on the second element of the pair?
- Subclass/inherit standard containers?
- Why is template argument deduction disabled with std::forward?
- Is the order of iterating through std::map known (and guaranteed by the standard)?
- How to get a random element from a C++ container?
- how do you insert the value in a sorted vector?
- What is the point of a private pure virtual function?
- c++ sort keeping track of indices [duplicate]
- Multidimensional std::array [duplicate]
- Reorder vector using a vector of indices [duplicate]
- Is the C++ std::set thread-safe?
- How to choose between map and unordered_map?
- Advantages of std::for_each over for loop
- C++ equivalent of StringBuffer/StringBuilder?
- Does std::stack expose iterators?
- Why does a push_back on an std::list change a reverse iterator initialized with rbegin?
- accessing a protected member of a base class in another subclass
- Why is the STL so heavily based on templates instead of inheritance?
- How to sort an STL vector?
- Using std::map where V has no usable default constructor
- C++ inheritance and member function pointers
- How can I make the map::find operation case insensitive?
- Comparing 3 modern c++ ways to convert integral values to strings
- C++ Virtual function being hidden