Can we inherit from a standard container (such as std::vector)? If so what are the implications?
Show answer and explanation
The language permits deriving from a standard container, but it is usually unsafe as a public polymorphic design: containers have no virtual destructor and were not designed as base classes. Prefer composition and expose only the operations your abstraction promises.
The language permits deriving from a standard container, but it is usually unsafe as a public polymorphic design: containers have no virtual destructor and were not designed as base classes. Prefer composition and expose only the operations your abstraction promises.
Connect the conclusion directly to the type, lifetime, ownership, overload-resolution rule, or library contract present in the question. State implementation dependence or a violated precondition explicitly instead of merely guessing output.