Extending a class template
2 answers
Your syntax is incorrect; you need to use:
template <typename T>
class Vector : public std::vector<T>
However, you should not propagate standard library containers through inheritance, if not for some other reason, because they do not have virtual destructors and are therefore inherently unsafe.
If you want to "improve" std::vector
, do it using composition (for example, with a member variable of the type std::vector
) or use non-member functions to provide additional functionality.
+19
a source to share